• 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: bind:toObject:withKeyPath:options: Unidirectional or Bidirectional?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bind:toObject:withKeyPath:options: Unidirectional or Bidirectional?


  • Subject: Re: bind:toObject:withKeyPath:options: Unidirectional or Bidirectional?
  • From: Jerry Krinock <email@hidden>
  • Date: Sat, 30 Jan 2010 10:33:52 -0800

On 2010 Jan 30, at 09:12, Keith Duncan wrote:

>>> Why are bindings A, B, C and D bidirectional but E is only unidirectional?
>>
>> Regarding A, B, C and D: Apparently, NSButton's implementation of bind:::: sets up observers in both directions when binding to the "value" binding.
>
> This isn't what happens, run the following code:

My Time Manager says I should take your word for it on that :>

> What NSButton does when it needs to change the value of it's bound to counterpart, is introspect the binding either through -infoForBinding: (or other means depending on where it stored the captured binding information, we'll assume the -infoForBinding: case for simplicity).
>
> It extracts the bound-to object (stored under NSObservedObjectKey), and the keypath (stored under NSObservedKeyPathKey) and invokes [observedObject setValue:newValue forKeyPath:observedKeyPath].

Ah, indeed, it would be rather inefficient to tell someone else to observe your changes, call you back and get a value.  Instead, just activate a branch in your own setter to push your changes out when one occurs.

That makes much more sense, and also gives another reason why this is not generally referred to as a "bidirectional" or "two-way" binding.  That implies symmetry, when in fact the mechanism in the two directions is quite different.

Good work, Keith.

_______________________________________________

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

References: 
 >bind:toObject:withKeyPath:options: Unidirectional or Bidirectional? (From: Jerry Krinock <email@hidden>)
 >Re: bind:toObject:withKeyPath:options: Unidirectional or Bidirectional? (From: Quincey Morris <email@hidden>)
 >Re: bind:toObject:withKeyPath:options: Unidirectional or Bidirectional? (From: Jerry Krinock <email@hidden>)
 >Re: bind:toObject:withKeyPath:options: Unidirectional or Bidirectional? (From: Keith Duncan <email@hidden>)

  • Prev by Date: Re: Tabbed windows
  • Next by Date: Google Irvine open house on the Jan 27th.
  • Previous by thread: Re: bind:toObject:withKeyPath:options: Unidirectional or Bidirectional?
  • Next by thread: Re: bind:toObject:withKeyPath:options: Unidirectional or Bidirectional?
  • Index(es):
    • Date
    • Thread