I generated managed objects in Swift language so not in Objective-C anymore. Do you know if Swift generation is not working yet?
I get one error on this line:
let modelURL = NSBundle.mainBundle().URLForResource("TA", withExtension: "mom")
2014-10-12 18:17:13.940 TA[1767:555144] CoreData: warning: Unable to load class named 'Trip' for entity 'Trip'. Class not found, using default NSManagedObject instead.
fatal error: unexpectedly found nil while unwrapping an Optional value
I have added data model to the project. What then?
It is not a good practice if you move model from one project to an other in Xcode. You will get this crash because app is unable to load model file.
If you need exact the same model to use in an other project as well, then open original model file in Finder, copy appropriate part of xml, then open target model file in Finder and past that xml part into.
I had the same issue with my application. I wanted to use core data on an existing project that I didn't initialize with core data selected.
Make sure that you change the name of the Model in two places.
let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("TA.sqlite")
And
let modelURL = NSBundle.mainBundle().URLForResource("TA", withExtension: "momd")!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With