two-way bindings and one-way bindings
two-way bindings and one-way bindings
- Subject: two-way bindings and one-way bindings
- From: Matt Neuburg <email@hidden>
- Date: Wed, 05 Jul 2006 19:09:25 -0700
- Thread-topic: two-way bindings and one-way bindings
I have an NSPopUpButton whose values are set up in IB. Its "selectedValue"
is bound to User Defaults values.thing.
This works fine. When the user chooses from the popup, "thing" in User
Defaults changes to match. Similarly, if my code changes "thing" in User
Defaults, the popup changes to match. I describe this as a "two way
binding". Cool.
However, I'd prefer to access this value thru an ivar called "thing" in
MyObject. So in MyObject's awakeFromNib I say:
[self bind:@"thing" toObject:[NSUserDefaultsController
sharedUserDefaultsController] withKeyPath:@"values.thing" options:nil];
This works, but only in one direction. When the user chooses from the popup,
and "thing" in User Defaults changes to match, "thing" in MyObject also
changes. But when my code changes "thing" in MyObject, "thing" in User
Defaults does not change. I describe this as a "one way binding". Alas.
So *why* is this second binding only one-way? Is there something else I need
to do, to make it work in both directions? Thx - m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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