【问题标题】:xcode 10 - core data migration String to Intxcode 10 - 核心数据迁移 String 到 Int
【发布时间】: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


    【解决方案1】:

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

    【讨论】:

    • 不,正如标题所暗示的那样 - 属性是 String,我要将它转换为 Int
    猜你喜欢
    • 2013-11-26
    • 1970-01-01
    • 2011-09-14
    • 1970-01-01
    • 2016-12-16
    • 1970-01-01
    • 1970-01-01
    • 2011-07-22
    • 2023-03-14
    相关资源
    最近更新 更多