简体   繁体   English

如何在 NSUserDefault 中使用 NSDictionary?

[英]how to use NSDictionary in NSUserDefault?

I want to know how can I use NSDictionary in NSUserDefault ?我想知道如何在NSUserDefault中使用NSDictionary I have to store name, points and time of user into the NSDictionary and dictionary into the user default.我必须将用户的姓名、积分和时间存储到NSDictionary ,并将字典存储到用户默认值中。

NSDictionary *dict = [[NSDictionary alloc] init];

[[NSUserDefaults standardUserDefaults] setObject:dict forKey:@"dict"];

[[NSUserDefaults standardUserDefaults] synchronize];

At the time of retrieval of data,在检索数据时,

dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"dict"]; 
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:yourData forKey:@"yourKey"];
[defaults synchronize];

id yourData = [defaults objectForKey:@"yourKey"];

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

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