Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with NSUserDefaultsController





On 31 Aug 2008, at 17:25, Keary Suska <> wrote:

8/31/08 10:13 AM, also sprach:

I've been playing around with bindings to NSUserDefaultsController in
a very simple app to test saving preferences, but the
[sharedUserDefaultsController save:self] method seems to return
immediately without waiting for the save operation to complete.

The save does actually take place, which I can see if I open the
plist file in Property List Editor, but if the very next line after
sending the save message is one which reads a property from the
plist, it's the old value which gets returned rather than the newly
saved one.

The -save: method is unintuitive in name. It does not, as you may think,
save changes to disk. It simply commits any changes to the NSUserDefaults
object. It's a no-op if appliesImmediately is YES. The only way to force a
save is to call -synchronize on NSUserDefaults.

Thanks but the problem is actually the exact opposite. The file IS being saved - it's the userdefaults object which doesn't contain the right value unless there's some short delay between the save and objectForKey messages.


Calling -synchronize on the userDefaults object makes no difference.

I'm already setting appliesimmediately to YES so that I can have Cancel and OK buttons, and in terms of saving/reverting the plist file it's working fine. Do I need to perform some action to connect the userdefaults object to the userDefaultsController object?

Mark

Ps. Email on the iPod touch is impossible - it's taken me about 40 minutes to write this cos the delete button keeps repeating and dfeleting half the message!
_______________________________________________


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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Problem with NSUserDefaultsController (From: Keary Suska <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.