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

时间:2022-12-20 13:42:59

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?

我怎样才能做到这一点?

1 个解决方案

#1


34  

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类参考的链接

#1


34  

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类参考的链接