Re: NSUserDefaults causing me fits
Re: NSUserDefaults causing me fits
- Subject: Re: NSUserDefaults causing me fits
- From: John Timmer <email@hidden>
- Date: Mon, 08 Sep 2003 22:23:54 -0400
>
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.
Well, this happens despite a synchronize message, and even if the pref file
hadn't previously existed (ie - everything I did with it was a change, so it
should have written out). Maybe the problem is that I'm creating the prefs
as a dictionary and handing it over all at once, so it doesn't see things as
changed. I'll try keeping one key out of the dictionary and setting it
afterwards to see if that triggers a write out.
>
>
> 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:
Ah, that was the problem - cat was enough to show that the file had the
right format. If I had to guess, it's the fact that the booleans show up as
"<false/>" rather than a key/value that causes it to flake out.
Thanks for the help on that one,
John
_______________________________________________
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.