iOS 8 和 iOS 8 下的 NSUserDefaults [英] NSUserDefaults in iOS 8 and under iOS 8

查看:42
本文介绍了iOS 8 和 iOS 8 下的 NSUserDefaults的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 NSUserDefaults 将数据保存在应用程序中,因此在 iOS 8 下删除应用程序后数据会被清除.但在 iOS 8 中删除应用程序后数据仍然存在.

I know NSUserDefaults saves data in a app, so data is cleared after deleting app under iOS 8. but data persists after deleting app in iOS 8.

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

以下代码适用于iOS 8(删除应用程序后数据被清除)

Below codes works in iOS 8 (data is cleared after deleting app)

NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.AppCompany.Appname"];

这段代码在 iOS 8 下能用吗?

Does this code works under iOS 8?

推荐答案

如果你在 ios Simulator 中运行你的应用程序 NSUserDefaults 将不会被清除.这是模拟器的bug.在ios设备上完美运行.

If you are running your application in ios Simulator NSUserDefaults will not be cleared . it is the simulator bug .It work perfectly in ios device.

这篇关于iOS 8 和 iOS 8 下的 NSUserDefaults的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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