3.3. Lightweight migration Approach (Core Data Application Practice Guide)

Source: Internet
Author: User

The persistence Store coordinator will try to open the original persisted store with the new version of the template, but that is the old template, the old format, of course, error. Now all you have to do is migrate the existing persisted data area to match the new model.

How to migrate?

When does the migration take place?

When adding a store to nspersistentstorecoordinator.

So how do you add it?

The answer is that by placing the following options in Nsdictionary, the migration of the storage area will be completed automatically.

  • If the nsmigratepersistentstoresautomaticallyoption passed to Nspersistentstorecoordinator is yes, then the core Data will try to migrate the low-version persistent storage to the latest version of the model
  • If the nsinfermappingmodelautomaticallyoption passed to Nspersistentstorecoordinator is yes, then core Data will try to automatically infer the "Source Model entity" in the most reasonable way. Which property in the target model entity corresponds to one of the properties in the
  • When you open the above two options, it is a lightweight migration (lightweight migration).

The program is modified as follows:

Note: Migrate is "migrated" and infer is "inferred".

3.3. Lightweight migration Approach (Core Data Application Practice Guide)

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.