【发布时间】:2015-10-30 05:28:59
【问题描述】:
这段代码使我的应用程序崩溃
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("appTest", withExtension: "momd")!
return NSManagedObjectModel(contentsOfURL: modelURL)!
}()
特别是在let modelURL = 赋值(我放置了断点)
与:
fatal error: unexpectedly found nil while unwrapping an Optional value
所以我认为这可能意味着
1- 找不到 appTest.momd 文件,因为名称更改或
2- 它只是尚未创建。
有什么想法吗?
【问题讨论】:
-
您确定您的项目中包含
appTest.momd文件吗? -
而且,请告诉我,错误信息是什么?
-
@Alexander 我该如何检查?
-
@JodyHagins 我刚刚编辑了我的问题,出现了错误
标签: ios swift core-data nsmanagedobject