简体   繁体   中英

CoreData removes all objects after updating Model.xcdatamodeld

I am using MagicalRecord and Swift.

Here is my case:

  • user has some history items in database. (user had some fitness sessions)
  • Model.xcdatamodeld updated, like added new optimal attribute
  • user starts the app and all history items removed.

Why? Any ways do handle that?

If you are updating the xcdatamodeld file after running on your device and then running again, the chances are there is a conflict in xcdatamodeld files. You need to add a new version everytime you make changes to your data model. The current active xcdatamodel file is stored having omo extension. If this was the case the app would've crashed immediately and I see you updating your model maybe its something to do with MagicalRecord.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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