Core-Data iPhone: could not locate an NSManagedObjectModel

Ok.

Placing the following code inside of the RootViewController’s viewDidLoad eliminates the error:

if (managedObjectContext == nil) 
{ 
    managedObjectContext = [(CoreDataBooksAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; 
    NSLog(@"After managedObjectContext: %@",  managedObjectContext);
}

I found someone with a similar problem here on SO: link text

As Aryeh pointed out in that post: “In short you are trying to fetch an entity from an objectContext that hadn’t been set up yet. Your options therefore are to set it up right then or do elsewhere in the app before this view loads.”

Leave a Comment