简体   繁体   中英

Adding CoreData to existing Project

I am trying to add CoreData to an existing project and there is strange error...

I get the error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot create an NSPersistentStoreCoordinator with a nil model'

in RootView there is a warning in:

- (NSFetchedResultsController *)fetchedResultsController;

in line:

_fetchedResultsController.delegate = self;

and it says:

warning: class 'RootViewController' does not implement the 'NSFetchedResultsControllerDelegate' protocol

any ideas?

argh!

sorry for even asking, I just missed that I changed the name of .xcdatamodel

I needed just to change the name in managedObjectModel and persistentStoreCoordinator

hope it'll help someone anyway.

I was getting the same exception.

My issue was that I had added the .xcdatamodeld file in the root directory of the project (with siblings Frameworks and Products ) instead of in the folder named after the project (with siblings Supporting Files , AppDelegate.h , etc.)

I tracked it down to this line: NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Foo" withExtension:@"momd"];

In this method: - (NSManagedObjectModel *)managedObjectModel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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