Re: bindings confusion
Re: bindings confusion
- Subject: Re: bindings confusion
- From: Lee Ann Rucker <email@hidden>
- Date: Tue, 20 Sep 2011 10:47:10 -0700
Define "doesn't work" - if you mean observeValue:forKeyPath:... doesn't get called, it's because that's a different relationship from bindings. With bindings, a change in one value causes a change in another. With observers, a change in one value causes a call to the observeValue method.
On Sep 20, 2011, at 2:13 AM, Torsten Curdt wrote:
> Before I was following the docs and wrote the bindings clue code myself
>
> http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaBindings/Concepts/HowDoBindingsWork.html#//apple_ref/doc/uid/20002373
>
> - (void)bind:(NSString *)binding toObject:(id)theObservedObject
> withKeyPath:(NSString *)theKeyPath options:(NSDictionary *)options
> {
> ...
> self.observedObject = theObservedObject;
> self.observedKeyPath = theKeyPath;
>
> [theObservedObject addObserver:self
> forKeyPath:theKeyPath
> options:NSKeyValueObservingOptionInitial
> context:nil];
> ...
> }
>
>
> Now I have found these posts suggesting that it is not required to (or
> even one should not) override bind:toObject:withKeyPath:options:
>
> http://www.tomdalling.com/blog/cocoa/implementing-your-own-cocoa-bindings
> http://stackoverflow.com/questions/1169097/can-you-manually-implement-cocoa-bindings
> http://stackoverflow.com/questions/366938/is-it-necessary-to-override-bindtoobjectwithkeypathoptions-in-an-nsview-subcl/
>
> But I see myself in the same camp:
>
> When I don't override bind:toObject:withKeyPath:options: my custom
> NSView's bindings do not work.
>
> Could someone clear this up?
>
> cheers,
> Torsten
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden