Re: Problem with NSUserDefaultsController
Re: Problem with NSUserDefaultsController
- Subject: Re: Problem with NSUserDefaultsController
- From: Keary Suska <email@hidden>
- Date: Tue, 02 Sep 2008 10:40:15 -0600
- Thread-topic: Problem with NSUserDefaultsController
9/2/08 2:37 AM, also sprach email@hidden:
> For what it's worth, the [sharedUserDefaultsController save:] message is still
> returning before performing the save, so if I send any other messages within
> my savePrefs method, userDefaults will still contain the old value - I'm
> beginning to wonder if this is a bug within NSUserDefaultsController.
As someone else suggested, it appears that the -save method uses a delayed
method call to update NSUserDefaults. Binding is a perfectly acceptable way
to do this. Alternatively, you can get the value directly from the defaults
controller, as it is always immediately changed there:
theValue = [[shared values] valueForKey:@"thevalue"];
Some other suggestions: storing the shared defaults and controller is really
just a waste of memory. They won't change across invocations. It would also
be a good idea to keep your types consistent: a slider expects to manipulate
a numeric value, and as you see it stores its value as a number in the
prefs. Your object property should also be an NSNumber, not an NSString.
Better yet, don't store it at all, and always ask NSUserDefaults for the
value. You'll get better extensibility with this encapsulation.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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