Re: NSUserDefaults causing me fits
Re: NSUserDefaults causing me fits
- Subject: Re: NSUserDefaults causing me fits
- From: Phill Kelley <email@hidden>
- Date: Tue, 9 Sep 2003 11:26:47 +1000
At 19:31 -0400 08/09/2003, John Timmer wrote:
>
On my app controller's awakeFromNib method, I'm creating a dictionary and
>
initializing the user defaults to that if there's no pre-existing defaults.
>
These values seem to take, though if I quit the app, the file doesn't get
>
written out.
This is the correct behavior. Only changes are saved in the prefs file.
>
If I then go through and update the defaults through a preferences window,
>
the file gets written out with the "synchronize" method. Unfortunately,
>
when I look over the file's contents, all the values appear to have one of
>
two keys (there are the right number, they're just listed as all being one
>
or the other of these two keys). Not surprisingly, this isn't helping much.
>
>
Does anyone know why this would happen or how to avoid it?
Are you using Property List Editor to inspect your preferences file? If so,
it sometimes gets confused about what it is showing you (presumably a bug).
Try looking at the defaults file in a text editor, or dump it from the
command-line via:
defaults read DOMAIN
where DOMAIN is typically com.organisation.application
If it looks OK in a text editor or when dumped, then you can put this down
to Property List Editor. If the problem still shows up, I'd be
double-checking my keys whenever I saved things into user defaults.
By the way, synchronize is only needed if you want to force the information
to be saved immediately. In my experience, the automatic save which occurs
when your app quits is sufficient. Any changes you make in your prefs area
are immediately available to your running app without needing to sync.
Regards, PK
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.