在iPhone App升级时强制重置NSUserDefault [英] force reset NSUserDefault on iPhone App upgrade

查看:424
本文介绍了在iPhone App升级时强制重置NSUserDefault的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当用户更新我的应用时,我都想强制重置为NSUserDefault。为什么我需要这个,因为每次更新都包含一些用户的新信息。由于NSUserDefault中已存在某些信息(令牌),我的应用程序不会调用我的Web服务。由于这个事实,我没有新的用户信息。而且我也不想为每个新版本写if..else语句。

i want to force reset to NSUserDefault whenever user update my app. why i need this because every update include some new information abt user. as some info (token) already present in NSUserDefault my app does not call to my web service. due to that fact i dont have new user info. and also i dont want to write if..else statement for every new release.

非常感谢。希望我的问题很清楚。

thanks so much. hope my question is pretty clear.

推荐答案

检查出来:

[NSUserDefaults resetStandardUserDefaults]

有关详情,请查看 NSUserDefaults类参考

您可以做的是保存当前版本的应用程序的默认值。用户打开应用程序的所有时间都会根据当前版本检查保存的版本。在更新的情况下,当前版本将与保存的版本不同,因此您知道是时候清理用户默认值了。清理后,保存当前版本的新值。

What you can do is save on the defaults the current version of your app. All the time that the user open the app you check the saved version against the current version. In the case of an update the current version will be different from the saved version, and so you know that it's time to clean the user defaults. After cleaned, you save the new value for the current version.

这篇关于在iPhone App升级时强制重置NSUserDefault的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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