[英]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. 我有2个版本的核心数据模型,我打算将旧版本迁移到新版本。
However even if the new version is ticked with the green icon in xCode, I'm not sure I'm using the current version. 但是,即使新版本在xCode中用绿色图标打勾,也不能确定我使用的是当前版本。
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: 例如,您可以为每个模型设置一个标识符(在界面构建器中),然后使用您的
NSManagedObjectModel
对象的versionIdentifiers
方法:
[[[[[self managedObjectContext] persistentStoreCoordinator] managedObjectModel] versionIdentifiers] anyObject]
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.