Re: Binding not setting model property
Re: Binding not setting model property
- Subject: Re: Binding not setting model property
- From: Quincey Morris <email@hidden>
- Date: Sat, 18 Jan 2014 20:25:30 -0800
On Jan 18, 2014, at 19:45 , Roland King <email@hidden> wrote:
> So perhaps the question is .. what property do I need to set on the NSTextField to get it to go back the other way? I've tried [ textField setValue:.. ] but that just throws an exception that setValue: isn't implemented on NSTextField, which it isn't, so I went back to setStringValue: But setting stringValue: changes the on-screen string, but doesn't trigger the binding to send the string back the other way.
I think you need to setObjectValue, not setStringValue. “objectValue” is the underlying property that all controls have, from which “intValue”, “stringValue” etc are derived, so presumably the text field “value” binding is bound to “objectValue”.
Alternatively, don’t use ‘set<anything>’ on the text field at all, but let the Browse button action method update the *data model*, and then let the binding change the text field. This may seem weird, because the button action method would have to apply the reverse transformer itself, but it’s actually cleaner, because it doesn’t make the button behavior depend on the text field.
_______________________________________________
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