繁体   English   中英

找不到模型CoreData + Swift

[英]Can't find model CoreData + Swift

我在iphone 6的xcode上运行应用程序时遇到问题。我不久前创建了该项目,但是由于开发团队将使用另一个数据库框架,因此未选中“使用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)!
    }()

该模型只是项目中的另一个源文件。 在Xcode中,使用File-> New-> File,然后在Core Data下可以选择一个模型文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM