• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: bindings confusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: bindings confusion
      • From: Torsten Curdt <email@hidden>
References: 
 >bindings confusion (From: Torsten Curdt <email@hidden>)

  • Prev by Date: Re: Duplicating an edited document in 10.7.1
  • Next by Date: Re: bindings confusion
  • Previous by thread: bindings confusion
  • Next by thread: Re: bindings confusion
  • Index(es):
    • Date
    • Thread