Re: Binding not setting model property

2014-01-19 Thread Ken Thomases
On Jan 18, 2014, at 9:45 PM, Roland King wrote: > That was one point of confusion for me right at the start. IB binds the > 'value' property but as far as I could tell, NSTextField doesn't have such a > property, calling 'value' or 'valueForKey:@"value"' on it just raises as > exception, so I a

Re: Binding not setting model property

2014-01-18 Thread Quincey Morris
On Jan 18, 2014, at 22:44 , Roland King wrote: > What derived property can I write on the view which removes that dependency? On Jan 18, 2014, at 20:54 , Quincey Morris wrote: > create a derived property on the view or window controller that’s based on > the data model property Sorry, what

Re: Binding not setting model property

2014-01-18 Thread Roland King
> > In practice, I never do it that way any more. I always create a derived > property on the view or window controller that’s based on the data model > property. So, from the views’ point of view, the view/window controller *is* > the data model, but it’s insulated from the real data model. (

Re: Binding not setting model property

2014-01-18 Thread Quincey Morris
On Jan 18, 2014, at 20:39 , Roland King wrote: > Really does look like the binding code only fires for at the end of > ..didFinishEditing: and not for any programatic set of any property on the > object, at least not one I've been able to find. That actually makes a lot of sense. It’s quite p

Re: Binding not setting model property

2014-01-18 Thread Roland King
On 19 Jan, 2014, at 12:25 pm, Quincey Morris wrote: > On Jan 18, 2014, at 19:45 , Roland King 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 ex

Re: Binding not setting model property

2014-01-18 Thread Quincey Morris
On Jan 18, 2014, at 19:45 , Roland King 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, whi

Re: Binding not setting model property

2014-01-18 Thread Roland King
.. right so if I actually edit the NSTextField on-screen (it wasn't editable before, I made it so) *THEN* the binding gets called in the way I expected. So it would seem that only a user-initiated change of the value fires the binding in reverse (which is what the example binding code in the Ap

Re: Binding not setting model property

2014-01-18 Thread Roland King
Yes I've bound to the value property in IB. That gets the value from the model object into my NSTextField perfectly via the transformer. It reads the underlying NSURL property which it's bound to, applies the transformer, and sets the text into the NSTextField (presumably by setting the stringVa

Re: Binding not setting model property

2014-01-18 Thread Dave Fernandes
How are you setting up the binding? Normally you bind to the value property of the NSTextField (not stringValue). See Cocoa Bindings Reference (NSTextField Bindings). On Jan 18, 2014, at 9:41 PM, Roland King wrote: > I have a model object with a codeURL property which is readwrite and is an >

Re: Binding not setting model property

2014-01-18 Thread Roland King
... and I tried expressing the URL as an NSString property too, with no transform. Similarly calling [ textField setStringValue: ] didn't cause the setter in the model object to be invoked. That surprised me, I thought binding an NSTextField to an NSString in the model object would be a very si

Binding not setting model property

2014-01-18 Thread Roland King
I have a model object with a codeURL property which is readwrite and is an NSURL. I have an NSTextField in the NSView subclass with the value bound to the codeURL property with a custom transform which turns a URL into a string (and deals with nil and another edge case). The transform is rev