views:

21

answers:

1

I'm getting a dictionary representation of the current settings in NSUserDefaults, as NSDictionary.

That was pretty easy using the -dictionaryRepresentation method. However, I need to write that back again. I couldn't find a method to do that easily. Maybe it's just too hot in my office?

+1  A: 

You don't need dictionaryRepresentation.

What you want to do is access your keys directly, and re-set them when they're modified:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
id obj = [defaults objectForKey:@"<key>"];
// MODIFY OBJ
[defaults setObject:obj forKey:@"<key>"];
Can Berk Güder
There must be a simpler way
dontWatchMyProfile
It's pretty simple as it is, if you ask me.
Can Berk Güder
Well, I made a deep copy. Was by far simpler ;) But thanks anyways, it's also a solution that works for a small set of settings. Otherwise you would code yourself crazy.
dontWatchMyProfile