FROM : Jens Alfke
DATE : Sat May 31 20:32:39 2008
On 31 May '08, at 11:14 AM, vince wrote:
> What's the best way to maintain the value of the textField using
> Bindings?
I've never worked with user defaults using bindings, but it's really
easy to do programmatically:
To store:
[[NSUserDefaults standardUserDefaults] setObject: [textfield
stringValue] forKey: @"MyDefault"];
To retrieve:
[textfield setObjectValue: [[NSUserDefaults standardUserDefaults]
objectForKey: @"MyDefault"]];
(The reason for using -setObjectValue: in the second line is that,
unlike -setStringValue:, it doesn't barf if the value is nil.)
—Jens
DATE : Sat May 31 20:32:39 2008
On 31 May '08, at 11:14 AM, vince wrote:
> What's the best way to maintain the value of the textField using
> Bindings?
I've never worked with user defaults using bindings, but it's really
easy to do programmatically:
To store:
[[NSUserDefaults standardUserDefaults] setObject: [textfield
stringValue] forKey: @"MyDefault"];
To retrieve:
[textfield setObjectValue: [[NSUserDefaults standardUserDefaults]
objectForKey: @"MyDefault"]];
(The reason for using -setObjectValue: in the second line is that,
unlike -setStringValue:, it doesn't barf if the value is nil.)
—Jens
| Related mails | Author | Date |
|---|---|---|
| vince | May 31, 20:14 | |
| Jens Alfke | May 31, 20:32 |






Cocoa mail archive

