【问题标题】:No managed objects able to see after lightweight migration轻量级迁移后看不到托管对象
【发布时间】:2016-05-03 06:12:06
【问题描述】:

创建了一个新模型,因为属性已添加到实体中,并且父实体已删除。然后使用来自数据库的新模型,无法加载托管对象。如果我切换回旧数据库,我可以看到托管对象。我做错了什么?

【问题讨论】:

    标签: ios core-data core-data-migration


    【解决方案1】:

    忘记添加:NSMigratePersistentStoresAutomaticallyOptionNSInferMappingModelAutomaticallyOption

    现在它的持久存储加载看起来像:

    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
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-17
      • 1970-01-01
      • 1970-01-01
      • 2021-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多