CoreData database migration operations and coredata database migration

Source: Internet
Author: User

CoreData database migration operations and coredata database migration

The procedure for migrating the CoreData database is based on Xcode7.

 

1. Add a new database. Select the current database version: Editor-> Add Model Verson to create a new database version.

2. command + N to create a ing model. iOS-> CoreData-> Mapping Model-> Next, select the old database version-> Next, select the new database version-> Create.

3. Select a database, the first tab on the right toolbar-> ModelVerson-> current, and select the latest database version.

4. Select the latest database to create a new object class .:

5. in AppDelegate. find the method in the m file:-(NSPersistentStoreCoordinator *) persistentStoreCoordinator;, and add a dictionary to options in the implementation of the method: @ {NSInferMappingModelAutomaticallyOption: @ (YES), callback: @ (YES )}. for example:

After the above process, you can complete the database migration.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.