Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Model URL for Core Data

I want to using core data to save and load my data that I get from server:

 private lazy var managedObjectModel : NSManagedObjectModel = {
    let modelURL = NSBundle.mainBundle().URLForResource(self.manageObjectModelName, withExtension:"mom")!
    return NSManagedObjectModel(contentsOfURL: modelURL)!
}()

I have an error

unexpectedly found nil

while unwrapping an Optional value in this code. And my persistanceStoreCooardinator storage and mainQueueContext storage are nil. How can solve this problem?

like image 635
ava Avatar asked Dec 28 '25 07:12

ava


1 Answers

Typo in this line mom instead of momd:

let modelURL = NSBundle.mainBundle().URLForResource(self.manageObjectModelName, withExtension:"momd")!
like image 182
pedrouan Avatar answered Dec 30 '25 23:12

pedrouan