【发布时间】:2016-05-03 06:12:06
【问题描述】:
创建了一个新模型,因为属性已添加到实体中,并且父实体已删除。然后使用来自数据库的新模型,无法加载托管对象。如果我切换回旧数据库,我可以看到托管对象。我做错了什么?
【问题讨论】:
标签: ios core-data core-data-migration
创建了一个新模型,因为属性已添加到实体中,并且父实体已删除。然后使用来自数据库的新模型,无法加载托管对象。如果我切换回旧数据库,我可以看到托管对象。我做错了什么?
【问题讨论】:
标签: ios core-data core-data-migration
忘记添加:NSMigratePersistentStoresAutomaticallyOption、NSInferMappingModelAutomaticallyOption。
现在它的持久存储加载看起来像:
var error: NSError?
do {
try coordinatorMain.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: mainDB, options: [NSSQLitePragmasOption: ["journal_mode" : "DELETE"], NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true])
} catch var error1 as NSError {
error = error1
}
【讨论】: