A
A
Alexander Zarochintsev2014-05-12 17:11:25
Objective-C
Alexander Zarochintsev, 2014-05-12 17:11:25

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

2 answer(s)
A
An, 2014-05-16
@Kovalskiy

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...

H
Headmast, 2014-05-12
@Headmast

www.azoft.ru/blog/database-migration-ios-applications

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question