If the iOS app uses coredata and has database updates (new tables, fields, and other operations) in the previous version, overwrite the installationProgramTo migrate the coredata database, perform the following operations:
1. Select Your mydata. xcdatamodeld file and choose editor> Add model version from the menu, for example, mydata2.xcdatamodel.
2. Set the current version
Select the parent mydata. xcdatamodeld, and select the current template as mydata2 in versioned core data model of inspector.
3. Modify the new data model mydata2 and add fields and tables to the new file.
4. Delete the original class file and regenerate the next class.
In appdelegate
[HTML]
Nsdictionary * optionsdictionary = [nsdictionary dictionarywithobjectsandkeys: [nsnumber numberwithbool: Yes],
Nsmigratepersistentstoresautomaticallyoption, [nsnumber numberwithbool: Yes],
Nsinfermappingmodelautomaticallyoption, nil];
If (! [Persistentstorecoordinator addpersistentstorewithtype: nssqlitestoretype
Configuration: Nil
URL: storeurl
Options: optionsdictionary
Error: & error]) {www.2cto.com
Nslog (@ "failed to add persistent store with type to persistent store coordinator ");
}
Add * optionsdictionary. The original options: Nil is changed to options: optionsdictionary.
5. recompile the program.