diff --git a/BIND/Classes/BNDBinding.m b/BIND/Classes/BNDBinding.m index 8df798d..feb91a1 100644 --- a/BIND/Classes/BNDBinding.m +++ b/BIND/Classes/BNDBinding.m @@ -22,7 +22,7 @@ @interface BNDBindingKVOObserver : NSObject @property (nonatomic, copy, readonly) NSString *keyPath; -@property (nonatomic, weak, readonly) BNDBinding *binding; +@property (nonatomic, strong, readonly) BNDBinding *binding; + (instancetype)observerWithKeyPath:(NSString *)keyPath binding:(BNDBinding *)binding; @@ -41,8 +41,8 @@ @interface BNDBinding () @property (nonatomic, strong) NSValueTransformer *valueTransformer; @property (nonatomic) BOOL shouldSetInitialValues; -@property (nonatomic, strong) BNDBindingKVOObserver *leftObserver; -@property (nonatomic, strong) BNDBindingKVOObserver *rightObserver; +@property (nonatomic, weak) BNDBindingKVOObserver *leftObserver; +@property (nonatomic, weak) BNDBindingKVOObserver *rightObserver; @property (nonatomic) SEL transformSelector; @property (nonatomic) SEL reverseTransformSelector; @@ -273,15 +273,17 @@ - (void)setupObservers { [self removeObservers]; if (self.direction == BNDBindingDirectionLeftToRight || self.direction == BNDBindingDirectionBoth) { - self.leftObserver = [BNDBindingKVOObserver observerWithKeyPath:self.leftKeyPath - binding:self]; + BNDBindingKVOObserver *observer = [BNDBindingKVOObserver observerWithKeyPath:self.leftKeyPath + binding:self]; + self.leftObserver = observer; [self.leftObserver observe:self.leftObject]; } if (self.direction == BNDBindingDirectionRightToLeft || self.direction == BNDBindingDirectionBoth) { - self.rightObserver = [BNDBindingKVOObserver observerWithKeyPath:self.rightKeyPath - binding:self]; + BNDBindingKVOObserver *observer = [BNDBindingKVOObserver observerWithKeyPath:self.rightKeyPath + binding:self]; + self.rightObserver = observer; [self.rightObserver observe:self.rightObject]; } }