yershuachu
yershuachu

Reputation: 788

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?

Upvotes: 5

Views: 4160

Answers (2)

funroll
funroll

Reputation: 37093

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

Upvotes: 4

yershuachu
yershuachu

Reputation: 788

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.

Upvotes: 14

Related Questions