我有这个属性国家
它有一个属性State,它的类型为String,但应该是Int
所以我创建了一个新的数据模型版本(用绿色标记检查)
我还将此代码添加到persistentContainer:
let container = NSPersistentContainer(name: "Exchange")
let description = NSPersistentStoreDescription()
description.shouldMigrateStoreAutomatically = true
description.shouldInferMappingModelAutomatically = true
container.persistentStoreDescriptions = [description]
但是当我更新应用程序时 - 它崩溃了:
***由于未捕获的异常'NSInternalInconsistencyException'终止应用程序,原因:'无法创建支持目录(无法创建目录)'
从我的理解 - 从String到Int的自动迁移是这个的原因......
我如何解决它?我需要手动迁移吗?
谢谢!