简体   繁体   English

核心数据,NSManagedObject 在应用版本之间发生变化

[英]core data, NSManagedObject changed between app versions

I have an app at the App-Store right now that uses Core-Data with persistent store to save the data as SQL-Lite-store-type, locally on the device.我现在在 App-Store 有一个应用程序,它使用带有持久存储的 Core-Data 将数据保存为 SQL-Lite-store-type,在设备上本地保存。

Actually the Model is very simple, I have only one NSManagedObject in it, called "Product".其实Model很简单,我里面只有一个NSManagedObject,叫做“Product”。

In the next version I want to edit "Product" properties in the following way: add a new property and remove 5 properties.在下一个版本中,我想通过以下方式编辑“产品”属性:添加一个新属性并删除 5 个属性。 (Without the app crashing because of the inconsistency...) (没有应用程序因为不一致而崩溃......)

Plus, on the first launch of the application after the user upgrade I want to delete the old stored-DB , because it won't be relevant to the application any more.另外,在用户升级后第一次启动应用程序时,我想删除旧的 stored-DB ,因为它不再与应用程序相关。

I read "Core Data Model Versioning and Data Migration Programming Guide", but still not sure what is the best practice in this case.我阅读了“Core Data Model 版本控制和数据迁移编程指南”,但仍然不确定在这种情况下最佳实践是什么。 (Should I use "Lightweight Migration"?) (我应该使用“轻量级迁移”吗?)

Please help me...请帮我...

Using the Lightweight Migration is the simplest choice here.使用轻量级迁移是这里最简单的选择。 If all you are doing is adding properties, lightweight migration lets you avoid dealing with the inconsistency errors.如果您所做的只是添加属性,轻量级迁移可让您避免处理不一致错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM