核心数据迁移:如何删除核心数据堆栈?
我的计划是删除旧的核心数据堆栈(NSManagedObjectModel
.momd
文件和 NSPersistentStore
.sqlite
文件)因为:
- 我没有核心数据迁移的经验。
- 新的 .xcdatamodel 架构与旧的完全不同。
- 我可以安全地删除用户的旧数据,因为它全部存储在我们的服务器上,并且新应用程序无论如何都会从我们的服务器下载最新数据。
在这种情况下,完全删除是迁移的最佳方法吗?
My plan is to delete the old Core Data stack (the NSManagedObjectModel
.momd
file & the NSPersistentStore
.sqlite
file) because:
- I don't have experience with Core Data migrations.
- the new .xcdatamodel schema is completely different than the old one.
- I can safely delete the user's old data because it's all stored on our server and the new app downloads the latest data from our server anyway.
In this case, is complete deletion the best way to go about migration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的应用程序无论如何都需要互联网访问,那么这是一件完全有效的事情。否则,用户可能会留下一个空数据集(当您发现旧数据库与当前模型不兼容时,您可以删除旧数据库,但如果不访问服务器则无法重新填充它)。
从技术上讲,这是一件微不足道的事情。当您设置
NSPersistentStoreCoordinator
时:It is a perfectly valid thing to do if your app requires internet access anyway. Otherwise users may be left with an empty data set (you delete the old database when you find it's incompatible with the current model, but you cannot re-populate it without access to the server).
Technically, that's a trivial thing to do. When you set up the
NSPersistentStoreCoordinator
:如果您创建一个空白的 Core Data 应用程序,您可以在应用程序委托中的 Apple 注释中找到必要的代码:
If you create a blank Core Data application you find the necessary code in Apples comments in the Application Delegate: