Re: two-way bindings and one-way bindings
Re: two-way bindings and one-way bindings
- Subject: Re: two-way bindings and one-way bindings
- From: George Orthwein <email@hidden>
- Date: Wed, 5 Jul 2006 23:56:37 -0400
I think of it as NSUserDefaultsController is "bindings aware",
NSPopUpButton is "bindings aware", but your MyObject is not.
To make it bindings aware, you need to do the same stuff you'd do to
a custom view... such as the joystick control in mmalc's Graphics
Bindings example. Basically, it's implementing
bind:toObject:withKeyPath:options: so that you can store the bound
object and keypath, so that when you modify MyObject, it can send
updates to the bound object via KVC.
That was most likely a horrible explanation, look here instead. :)
http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/Concepts/HowDoBindingsWork.html#//apple_ref/doc/uid/
20002373-196748
I wondered once in a post why the "KVO part" is handled automatically
with bind:toObject:withKeyPath:options: but the "KVC part" is not set
up automatically. (Or, as you put it, one-way is given for free but
not two-way.) I just chalk it up to something with the underlying
technology that I don't understand.
...
On further thought, maybe it's all there in that link. We can see the
implementations of bind:toObject:withKeyPath:options: set up the KVO
part. So if you don't re-implement it, and you use your ivar name as
the binding name, you can get that part "for free". Sending changes
to the bound object via KVC just has to be done in a different place.
Starting to make sense, I think... but still need to think on it more.
George
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden