> 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"];


You know, I could swear blind that I had already tried that, but I've just done it now and it works! Maybe that's what comes of coding at 1am!


Some other suggestions: storing the shared defaults and controller is really
just a waste of memory. They won't change across invocations.


With the overhead of Objective C messaging, isn't it more efficient to obtain once and store the shared defaults and controller for later use? Admittedly, we're probably splitting hairs here with a very small number of messages vs very small memory requirement, but I was always taught that space is cheaper than time. If necessary, space can be reclaimed whereas (cpu) time can't.


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.

Yes, that was just laziness on my part as I played around with this. This particular app will never actually do anything, I was simply trying to see how it will work when I start writing the preferences routines for my real application. The types will definitely match when I do it for that one! :)

M

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to