开发者

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>"];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜