如何在NSUserDefault中使用NSDictionary? [英] how to use NSDictionary in NSUserDefault?

查看:75
本文介绍了如何在NSUserDefault中使用NSDictionary?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在NSUserDefault中使用NSDictionary?我必须将用户的名称,点数和时间存储到NSDictionary中,并将字典存储到用户默认值中.

I want to know how can I use NSDictionary in NSUserDefault ? I have to store name, points and time of user into the NSDictionary and dictionary into the user default.

推荐答案

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

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

[[NSUserDefaults standardUserDefaults] synchronize];

在检索数据时,

dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"dict"]; 

这篇关于如何在NSUserDefault中使用NSDictionary?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆