I am using Core data with iOS 9.0, iPhone4 Simulator & Xcode 9.2.
While loading momd
file application crashes with nil value.
Although i already added Address.xcdatamodel
file to bundle resource & target membership checkbox selected.
lazy var managedObjectModelForAddress: 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 = Bundle.main.url(forResource: "Address", withExtension: "momd")!//Crashes here.
return NSManagedObjectModel(contentsOf: modelURL)!
}()
I was using many .xcdatamodel
files some of them get worked with Solution1 & some with solution 2
Solution 1:
.xcdatamodel
from xcode & save it somewhere, & re add it.Solution 2:
Delete App from simulator
Create new .xcdatamodel
& copy all contains to new .xcdatamodel
file