Re: bind:toObject:withKeyPath:options: Unidirectional or Bidirectional?
Re: bind:toObject:withKeyPath:options: Unidirectional or Bidirectional?
- Subject: Re: bind:toObject:withKeyPath:options: Unidirectional or Bidirectional?
- From: Keary Suska <email@hidden>
- Date: Tue, 2 Feb 2010 11:06:08 -0700
On Feb 2, 2010, at 8:42 AM, Jerry Krinock wrote:
> So now we have this paradox:
>
> 1. "Cocoa Bindings Programming Topics" says that bindings are bidirectional.
> 2. bind:toObject:withKeyPath:options: documentation says it "establishes a binding"
> 3. bind:toObject:withKeyPath:options: implementation establishes something which
> is unidirectional.
No paradox, as I see it, because #3 is not precisely true. There is nothing in the docs that says it is unidirectional, except in the sense that there is always an active and passive partner (perhaps what Quincey meant by "asymmetrical").
As I understand the basic implementation of bind:toObject:withKeyPath:options:
a. The receiver reads the value of keyPath of object, ostensibly storing it in its bound property (1st argument), then starts KVO on the object for key path.
b. Any time the receiver changes the bound property it issues a setValue:forKeyPath: message to the bound-to object.
c. Any time the receiver receives an observeValueForKeyPath: message from the bound-to object, it reads the value of keyPath of object, ostensibly storing it in a property identified by the first argument.
So, per the above, there is communication going both ways: the receiver is the active partner, doing a push-pull. The bound-to object doesn't even know (outside of the scope of KVO) that it is bound to another object, and doesn't do anything in that regard. In this sense, and in this sense alone, we could say that the binding is unidirectional.
Throwing my 2ยข into the mix,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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