Bindings - newbie question
Bindings - newbie question
- Subject: Bindings - newbie question
- From: "Oleg Krupnov" <email@hidden>
- Date: Tue, 2 Sep 2008 08:25:04 +0300
I have two objects: a MyDocument (NSDocument subclass) and a custom
MyController controller (NSObject subclass). In the MyDocument there
is "currMode" property. The controller class also has the currMode
property. I want these two properties to be bound to each other
two-way, so that when either of the properties changes, the other
updates respectively.
What I do:
>From within MyDocument's windowControllerDidLoadNib message:
[myController bind: @"currMode" toObject: self withKeyPath:@"currMode"
options:nil];
I do not override bind, unbind etc. of MyController relying on the
default implementation of bindings in NSObject.
Now when the myController's currMode properties changes by its view,
nothing happens in MyDocument. It's setCurrMode is not sent.
What am I doing wrong?
I have two accompanying questions:
1) Should I send the bind message to myDocument to observe
myController as well? I used to think that bindings are two-way
inherently, i.e. the object whose "bind" message is invoked, stores
its observed object and when the observer's property changes, it
updates the observed object automatically. Am I wrong?
2) Am I allowed to send [myController setCurrMode:] in order for the
binding to fire, or am I obliged to always send [myController
setValue:... forKey:@"currMode"] for this?
_______________________________________________
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