无法找到CoreData + Swift模型

时间:2015-08-10 16:39:10

标签: ios swift core-data

我在xcode for iphone 6上运行应用程序时遇到问题。我刚刚创建了该项目但是没有检查Use CoreData选项,因为开发团队将使用另一个数据库框架。我尝试在AppDelegate.swift文件中添加额外的代码以使用CoreData,但项目的模型不存在。我现在有办法创建模型吗?异常发生在文件的managedObjectModel部分:

    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("Tiempos", withExtension: "momd")!
       return NSManagedObjectModel(contentsOfURL: modelURL)!
    }()

1 个答案:

答案 0 :(得分:0)

该模型只是项目中的另一个源文件。在Xcode中使用File - >新 - >文件,然后在核心数据下,您将能够选择模型文件。