Answer the question
In order to leave comments, you need to log in
Changing the model (CoreData) - how to deal with the error?
Good day, I recently ran into a problem, I have an application that uses CoreData to store data, in fact, the essence of the problem is this: I created a model, filled it with entities and fields, the application works stably (as it should work - already in the AppStore ) - but when I change any field or add a new one in the model and launch the application, it crashes, I have to delete it and reinstall it, then everything is OK, tell me, please, how can this be avoided? So that users do not even feel it (that there have been changes in the database).
Surely there are ways?
Answer the question
In order to leave comments, you need to log in
You need to migrate. There are two types:
1. simple (lightweight), in this case you are required to make "three clicks", saving the old storage model. Core date will do the rest for you. But there are small restrictions on changing the model, just adding entities, renaming, etc. google for the tags "lightweight core data migration". Oh yes, the old model must be saved before changes (this is important!). those. you created the essence of the Car, added something to it and settled on the finished version. save the model and do not touch it, and make all new changes in the new model. xcode helps to manage different versions of models.
2. all handles when you can't use simple migration due to significant model change
All this is detailed in off. documentation (well, or the same Google)
https://developer.apple.com/library/ios/documentat...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question