Re: Binding an NSTextField
Re: Binding an NSTextField
- Subject: Re: Binding an NSTextField
- From: Mike Abdullah <email@hidden>
- Date: Fri, 4 Jul 2008 09:53:04 +0100
On 4 Jul 2008, at 06:15, Alex Wait wrote:
I have two methods setTheString and theString.
They return the value of another NSTextField on my window.
In IB I binded the value of the textField to App Controller and the
Model
Key Path to "theString".
theString() is only called when the app first starts up.
Firstly, it's -theString, not theString().
What you are doing sounds like a big no-no in MVC design. It sounds to
me like your code does something like:
- (NSString *)theString
{
return [textField stringValue];
}
In which case, how on Earth is the binding supposed to know when the
result of that method has changed? It is not KVO compliant.
Instead, you want to create a perfectly *standard* accessor method for
the -theString and -setTheString: that returns an instance variable.
Then, bind both of your text fields to it. That will ensure proper KVO
compliance.
_______________________________________________
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