ios - CoreData轻量级迁移后无法在新属性中保存数据
问题描述
我正在使用 CoreData,并且正在将新属性添加到实体中进行轻量级迁移。迁移过程运行良好.. 添加了新属性并且旧数据完好无损。但问题是新的 xcdatamodeld 版本显示新添加的属性为空白。当我向属性添加新数据时,不会存储数据。
这是我添加到正在创建持久容器对象的应用程序委托的代码:
let container = NSPersistentContainer(name: "myAppName")
let description = NSPersistentStoreDescription()
description.shouldMigrateStoreAutomatically = true
description.shouldInferMappingModelAutomatically = true
container.persistentStoreDescriptions = [description]
迁移正常进行,但来自旧数据模型的数据未显示在我的表格视图中,并且我添加到数据库中的新数据没有持久性。
解决方案
推荐阅读
- python - 编写拆分函数和分配变量的最短方法?
- python - Pytest E DeprecationWarning: defusedxml.lxml 不再受支持,将在未来版本中删除
- botframework - 用户登录后更换 OAuthPrompt 卡
- php - 在非 WordPress 页面上显示 WordPress 博客文章
- r - 在 r 中订购 stings 列表
- swift - 是否可以缩短 DispatchQueue 中的延迟?
- python - 在任何地方在 python 上运行任务时导入错误
- java - 我可以在我的一个测试课程中获得 Spring @Value,但不能在其他课程中获得
- javascript - 使用javascript设置值输入,输入值在焦点上会消失
- yellowbrick - 'Ridge' 不是 CV 正则化模型;改用 ManualAlphaSelection