简体   繁体   English

如何在NSUserdefaults中存储NSDictionary以及如何从中检索它

[英]how to store NSDictionary in NSUserdefaults and how can I retrieve from it

I am getting some info from web server like this. 我从这样的网络服务器获取一些信息。

970,
Aditya2,
B,
JNTU1,
"Ram@gamil.com"

I need to store these values and I need to retrieve it from there where I want. 我需要存储这些值,我需要从我想要的地方检索它。

I found NSDictionary is correct for this. 我发现NSDictionary对此是正确的。

I need to save these values in NSDictionary. 我需要在NSDictionary中保存这些值。

How can I do this? 我怎样才能做到这一点?

To store and then receive: 存储然后接收:

[[NSUserDefaults standardUserDefaults] setObject:myDictionary forKey:@"dictionaryKey"];
//...
NSDictionary * myDictionary = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"dictionaryKey"];

Here's a link to the NSUserDefaults Class Reference 这是NSUserDefaults类参考的链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM