【发布时间】:2019-08-10 05:31:36
【问题描述】:
我有这个属性国家
它有一个State属性,它的类型是String,但应该是Int
所以我创建了一个新的数据模型版本(用绿色标记选中)
我还将这段代码添加到 persistentContainer:
let container = NSPersistentContainer(name: "Exchange")
let description = NSPersistentStoreDescription()
description.shouldMigrateStoreAutomatically = true
description.shouldInferMappingModelAutomatically = true
container.persistentStoreDescriptions = [description]
但是当我更新应用时 - 它崩溃了:
*** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法创建支持目录(无法创建目录)”
据我了解 - 从 String 到 Int 的自动迁移是造成这种情况的原因...
我该如何解决? 我需要手动迁移吗?
谢谢!
【问题讨论】:
标签: ios swift core-data xcode10 core-data-migration