Reputation:
I am having trouble setting up my app's defaults. I create a dictionary and I register that dictionary as the defaults. When I check the defaults system from the Terminal, only the first key/value appears to have been saved. The other are ignored.
NSDictionary *defaultsDictionary = @{@"Task" : @"Check mail",
@"Interval" : @3,
@"SoundSetting" : @3,
@"Active" : @YES};
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultsDictionary];
[[NSUserDefaults standardUserDefaults] synchronize]; // Just for good measure
I can delete my defaults (using the proper method via the Terminal) and when I run my app the defaults are created each time for my app, so it's partially working at least - but only for the first value. Can someone help me understand what I'm doing wrong?
Upvotes: 0
Views: 58
Reputation: 41801
-registerDefaults doesn't cause the defaults to be saved. It's what you use to put in the "default defaults", the values you want to be there if the user hasn't set anything. This is very useful, but it doesn't sound like it's what you want.
You probably want -setObject:forKey:
Also you don't need to call synchronize.
Upvotes: 1