developer
2023-05-20 e12c7b4c22df631ebdcd16b2f98fbef8f738f92f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
//  RACSubscriptingAssignmentTrampoline.m
//  ReactiveCocoa
//
//  Created by Josh Abernathy on 9/24/12.
//  Copyright (c) 2012 GitHub, Inc. All rights reserved.
//
 
#import "RACSubscriptingAssignmentTrampoline.h"
#import "RACSignal+Operations.h"
 
@interface RACSubscriptingAssignmentTrampoline ()
 
// The object to bind to.
@property (nonatomic, strong, readonly) id target;
 
// A value to use when `nil` is sent on the bound signal.
@property (nonatomic, strong, readonly) id nilValue;
 
@end
 
@implementation RACSubscriptingAssignmentTrampoline
 
- (id)initWithTarget:(id)target nilValue:(id)nilValue {
    // This is often a programmer error, but this prevents crashes if the target
    // object has unexpectedly deallocated.
    if (target == nil) return nil;
 
    self = [super init];
    if (self == nil) return nil;
 
    _target = target;
    _nilValue = nilValue;
 
    return self;
}
 
- (void)setObject:(RACSignal *)signal forKeyedSubscript:(NSString *)keyPath {
    [signal setKeyPath:keyPath onObject:self.target nilValue:self.nilValue];
}
 
@end