How to recover the app settings in NSUserDefaults from a dictionary returned by -dictionaryRepresentation?
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?
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>"];
精彩评论