使用自定义 NSEntityMigrationPolicy 进行核心数据迁移 - 效率?
我的 iPhone 应用程序的核心数据模型正在发生变化,我有一个自定义映射模型和一个针对我的对象的 NSEntityMigrationPolicy。但是,我担心我的一些用户的核心数据库中将拥有数千个对象,是否有任何最佳实践可以使迁移尽可能高效,或者向用户传达加载新更新时发生的情况哪些会尝试迁移他们的数据?
My iPhone app's core data model is changing and I have a custom mapping model and an NSEntityMigrationPolicy for one of my objects. However, I am worried that some of my users will have thousands of objects in their core data base, are there any best practices for either making the migration as efficient as possible, or conveying to the user what's going on when they load the new update which will try to migrate their data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要警告用户应用程序需要更新数据存储,并且您可能应该提供一个“工作”对话框,这样应用程序看起来就不会挂起。
然而,迁移非常高效,因为它实际上只是更改存储上的映射。它不必实际实例化所有现有的托管对象,它只需更改存储中的字段名称。在极少数情况下,这本身可能会变得复杂,但大多数时候它几乎不会被注意到。
You need to warn the user that the app needs to update the data store and you should probably provide a "working" dialog so it doesn't look like the app has hung.
However, the migration is very efficient because it's really just changing the mapping on the store. It doesn't have to actual instantiate all the existing managed objects, it just changes the field names in the store. That can get complex itself in rare cases but most of the time it's barely noticeable.