【问题标题】:Swift CoreData EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)Swift CoreData EXC_BAD_INSTRUCTION(代码=EXC_I386_INVOP,子代码=0x0)
【发布时间】:2016-04-18 02:04:36
【问题描述】:

我正在尝试使用 CoreData,但每当我尝试存储对象时,我都会收到 EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) 错误。什么可能导致此错误?附带说明一下,我最初创建项目时并没有打算使用 CoreData,所以 CoreData 是我后来添加到我的项目中的(我不知道这是否是导致问题的原因)。

    lazy var managedObjectModel: NSManagedObjectModel = {
        // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
        let modelURL = NSBundle.mainBundle().URLForResource("repliaoutput", withExtension: "momd")!
        return NSManagedObjectModel(contentsOfURL: modelURL)! //this line is where the EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) error is
    }()

【问题讨论】:

    标签: ios swift core-data exc-bad-instruction


    【解决方案1】:

    从您的项目树中删除repliaoutput.xcdatamodel,然后将repliaoutput.xcdatamodeld(注意最后的“d”)拖放到您的项目中。清理,构建,它应该像魅力一样运行。

    【讨论】:

      【解决方案2】:

      检查您是否在 modelURL 中获取路径 如果您在后期创建了 Core Data,请在主项目目标中创建一个名为 repliaoutput 的新数据模型并再次构建
      新建文件 -> iOS - 核心数据 - 数据模型

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-05-30
        • 2016-02-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-04-20
        • 2016-08-08
        相关资源
        最近更新 更多