Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios xcode 10-核心数据迁移字符串到Int_Ios_Swift_Core Data_Xcode10_Core Data Migration - Fatal编程技术网

Ios xcode 10-核心数据迁移字符串到Int

Ios xcode 10-核心数据迁移字符串到Int,ios,swift,core-data,xcode10,core-data-migration,Ios,Swift,Core Data,Xcode10,Core Data Migration,我有这个属性国家 并且它有一个属性State,该属性的类型为String,但应该是Int 因此,我创建了一个新的数据模型版本(用绿色标记选中) 我还将此代码添加到persistentContainer: let container = NSPersistentContainer(name: "Exchange") let description = NSPersistentStoreDescription() description.shouldMigrateStoreA

我有这个属性国家

并且它有一个属性State,该属性的类型为String,但应该是Int

因此,我创建了一个新的数据模型版本(用绿色标记选中)

我还将此代码添加到persistentContainer

    let container = NSPersistentContainer(name: "Exchange")
    let description = NSPersistentStoreDescription()
    description.shouldMigrateStoreAutomatically = true
    description.shouldInferMappingModelAutomatically = true
    container.persistentStoreDescriptions = [description]
但是当我更新应用程序时,它崩溃了:

***由于未捕获异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法创建支持目录(无法创建目录)”

据我所知-从字符串到Int的自动迁移是造成这种情况的原因

我怎么修理它? 我需要手动迁移吗


谢谢

您是否添加了“二进制数据”类型的属性?如果有,请检查该属性的属性。如果选中了“允许外部存储”复选框,请取消选中该复选框,然后再次尝试运行该应用程序。这为我解决了问题


否,正如标题所暗示的那样-属性是String,我要将其转换为Int