xcode - xcdatamodel的多个版本是否意味着我们需要多个xcmappingmodel文件?

标签 xcode core-data core-data-migration xcdatamodel

我有多个版本的 xcdatamodel 文件:

app1.0.xcdatamodel
app1.1.xcdatamodel
app1.2.xcdatamodel (current)

这是否意味着我需要 xcmappingmodel 文件的多种组合来覆盖所有升级方案?

app1.0_to_app1.1.xcmappingmodel (had this already)
app1.1_to_app1.2.xcmappingmodel (is it iterative?)
app1.0_to_app1.2.xcmappingmodel (too much?)

谢谢!

最佳答案

Core Data 要求您创建一个映射模型,以从当前版本的数据存储转换到最新版本的数据存储。这意味着您需要制作一个从 v1 -> v2 到 v2 -> v3 和 v1 -> v3 的版本。

摘自核心数据版本控制和迁移指南

Tries to find a mapping model that maps from the managed object model for the existing store to that in use by the persistent store coordinator. Core Data searches through your application’s resources for available mapping models and tests each in turn. If it cannot find a suitable mapping, Core Data returns NO and a suitable error.

Note that you must have created a suitable mapping model in order for this phase to succeed.

正如本 Apple 文档中所讨论的 Core Data Mapping

关于xcode - xcdatamodel的多个版本是否意味着我们需要多个xcmappingmodel文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9162590/

相关文章:

swift - 关于核心数据保存对象的主要实体与次要实体

ios - 核心数据模型迁移

ios - 目标属性映射在 Coredata 迁移时未在 xcmod​​elmappingmodel 中显示新添加的属性

objective-c - 合并两个 iOS 核心数据持久存储的有效方法是什么?

ios - 如何在两个 UIViewControllers 上工作,一个在 swift 中,另一个在 objective-c 中..?

swift - UISearchController 在 iOS 11 Swift 4 上隐藏状态栏

ios - [NSFunctionExpression _propertyType] : unrecognized selector sent to instance

ios - Xcode 4.2 : How to import . 来自子项目的 h 文件

c++ - 编译外部 C++ 库以用于 iOS 项目

ios - 从不同核心数据实体获取数据并将结果转换为相应类的通用方法