CoreData: Replacing Data Model with New Version?
My app was originally published with a simple CoreData model. The original source code was lost and has since been rebuilt with an entirely new CoreData model.
Everything seemed to be alright until you consider installations of the old app that would be开发者_StackOverflow中文版 upgraded. I'm not entirely certain, but it appears that when installing the new version over the older one currently published on the App Store is problematic. I'm not getting any specific error messages, but I can't think of any other reasons why the app would be quickly crashing.
Is there a relatively simple way to replace the previous version's data model with the new one?
Check out the Core Data Model Versioning and Data Migration Programming Guide.
You'll need to create a new "version" of your schema and then migrate to the new schema.
Do the migration yourself. Read the previos database during the initial run and copy everything to the new database. If you jailbreak your device, you can access the file system using a file explorer and can copy the sqlite database file from the documents folder. You can find the coredata model by looking at the Sqlite tables(Ofcourse with a bit of trial and error).
精彩评论