简体   繁体   English

如何确定使用的是正确的核心数据模型版本?

[英]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.

相关问题 如果我不使用核心数据,如何使用iCloud Sync? - How can I use iCloud Sync if I'm not using Core Data? 如何为核心数据实现自定义映射模型? - How can I implement a custom mapping model for Core Data? 如何使用传统的关系数据库复制核心数据模型? - How can I replicate core data model using a traditional relational database? 我可以测试我的核心数据模型吗? - Can I Test My Core Data Model? 核心数据迁移:我添加的每个新模型版本都需要一个新的映射模型吗? - Core Data Migration: Do I Need a new Mapping Model for each new Model Version I Add? 如何在运行时从NSManagedObjectModel生成Core Data访问器类文件(.m / .h文件)? - How can I generate the Core Data accessor class files (.m/.h files) from an NSManagedObjectModel at runtime? 使用 Core Data 时如何覆盖属性上的 getter? - How can I override a getter on a property when using Core Data? 我可以对核心数据模型对象使用自定义初始化程序吗? - Can I use a custom initializer for a core data model object? 如何使用ReactiveCocoa确保始终对NSArray进行排序? - How can I make sure that an NSArray is always sorted, using ReactiveCocoa? 我不确定如何使UITableView Cell在Safari中打开链接? - I’m not sure how to make a UITableView Cell open a link in safari?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM