如何在更新 iPhone 应用程序时保留库目录中的用户数据?
根据Apple的iOS应用程序编程指南,应用程序保留文档和库目录。我的问题是库目录到底保留了什么?它是否也复制用户创建的文件/数据(如果存储在库目录中)或仅保留首选项和应用程序设置?
我的应用程序当前将用户数据存储在库目录中,用户在更新到新版本时丢失了数据。我不想再发生这样的事。
According to Apple's iOS Application Programming guide, application preserves documents and library directories. My question is what exactly library directory preserves? Does it copy user created files/data (if stored in library directory) as well or just preserves Preferences and application settings?
My app is currently storing user data in library directory and users lost their data on updating to newer version. I want not to happen this again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用户创建的文件和数据应存储在文档文件夹中。该文件夹中的内容也使用 iTunes 进行备份。
User created files and data should be stored in the documents folder. The contents in that folder is also backed up using iTunes.
您不仅应该将用户数据保存在文档目录中。
但您也应该只存储位于该目录中的文件的相对路径。如果您存储绝对路径,您的应用程序将在更新后找不到数据。
第一次应用更新,用户数据丢失(存储在 Documents 目录中)
Not only should you be saving user data in the documents directory.
But you should also only store relative paths to the files located in that directory. If you store the absolute path, your app won't find the data after an update.
First App Update, User Data Lost (was stored in Documents directory)