Re: NSTextField, bindings and saving changes
Re: NSTextField, bindings and saving changes
- Subject: Re: NSTextField, bindings and saving changes
- From: Mike Abdullah <email@hidden>
- Date: Sun, 14 May 2006 22:15:07 +0100
Why are you directly editing the NSText of the window, this seems by
far the wrong route!
Just talk to the defaults yourself, that way they will update the
text field for you:
[[[NSUserDefaultsController sharedDefaultsController] values]
setValue: @"replacement string" forKey: @"myKey"];
Mike.
On 12 May 2006, at 23:56PM, Sanford Selznick wrote:
I have an NSTextFiend in IB that is bound through shared user
defaults. If I type text into the field and quit, all changes are
saved just fine.
I have a button in the same window. When pushed, I
programmatically change the value in the NSTextField by getting an
NSText object for the field from the containing window. The change
appears on screen and everything seems fine. Unfortunately the new
value created through the NSText object is not saved through the
binding when I quit.
I've tried the following to no avail:
1. I'm calling commitEditing on the NSUserDefaultsController
instance created in the Nib.
2. I'm sure to pair endEditingFor with the fieldEditor as in:
NSText *t = [[self window] fieldEditor:YES forObject:myField];
[t replaceCharactersInRange:[t selectedRange]
withString:replacement];
[[self window] endEditingFor:myField];
3. I've even tried calling [[self window] makeFirstResponder:nil]
which I found in a related posting. (Shot in the dark.)
4. I've tried logging the string data from the NSTextField and have
verified that the NSTextField has the new value in it.
None of this has synchronized the data from the field through the
binding.
What am I missing?
Thank you,
Sanford
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com
This email sent to email@hidden
_______________________________________________
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