简体   繁体   中英

How can I be sure I'm using the correct version of the core data model?

I have 2 versions of the core data model, I'm going to migrate the old version to the new one.

However even if the new version is ticked with the green icon in xCode, I'm not sure I'm using the current version.

How can I be sure I'm using the correct version of the core data model ? Can I output it with the code ?

Thanks

Your application works only with current version (green icon). If you provide possibility to load file with old model you must implement automatic migration from every old version to current or customize this process. More details here: Introduction to Core Data Model Versioning and Data Migration Programming Guide

Can I output it with the code ?

For example you can set an identifier (in interface builder) for each model and then use versionIdentifiers method of you NSManagedObjectModel object:

[[[[[self managedObjectContext] persistentStoreCoordinator] managedObjectModel] versionIdentifiers] anyObject]

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM