gpt4 book ai didi

ios - 更新后的plist数据

转载 作者:行者123 更新时间:2023-11-30 14:18:30 26 4
gpt4 key购买 nike

我创建了一个 plist,用于在我的应用程序中存储所有用户数据,例如硬币数量、最佳得分、内部商店的一些衣服等等。现在,在发布前 1 天,我意识到更新应用程序后所有用户数据都将丢失。我说得对吗?

如果我不是,plists 如何工作?比方说,在我的应用程序的 1.0 版本中,我有一个包含用户硬币数量的 plist。然后我决定将一定数量的钻石添加到我的 plist 中,以便 2.0 版本中的 plist 由硬币和钻石组成。金币和钻石的默认值为0。

因此,用户下载了 1 版本,现在他有 0 个硬币。他玩了一段时间,赚了100个金币。然后他将应用程序更新到2版本。在这种情况下 plist 会发生什么?是否会被删除,添加新的,用户将默认拥有 0 个金币和 0 个钻石?或者根本不会更新?或者他仍然有 100 个金币,但有 0 颗钻石?

总而言之,我只是想知道其他开发者如何在设备本地存储用户的数据,而不使用外部数据库等。

附注这就是我创建 plist 的方式:

    var paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as! String
var path = paths.stringByAppendingPathComponent("UserInfo.plist")
var data = NSMutableDictionary(contentsOfFile: path)

var fileManager = NSFileManager.defaultManager()
if (!(fileManager.fileExistsAtPath(path)))
{
var bundle : NSString = NSBundle.mainBundle().pathForResource("UserInfo", ofType: "plist")!
fileManager.copyItemAtPath(bundle as String, toPath: path, error:nil)
}

最佳答案

And now, 1 day before release, I realized that after updating the app all user's data will be lost. Am I right

不,不一定。如果数据存储在用户默认值中或作为文件保存到应用程序沙箱的非 volatile 区域(例如 Documents 目录)中,则仅升级应用程序对其没有影响。

关于ios - 更新后的plist数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30825095/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com