Friday, February 17, 2012

Core Data: could not locate an NSManagedObjectModel for entity name 'XXX'

The following code is a simple trick to solve this issue. Add it to viewDidLoad or somewhere the code to access the entity.



if (managedObjectContext == nil)   { 
        managedObjectContext = [(YourAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; }

Remember to import "YourAppDelegate.h" !!!

1 comment:

  1. I have this exact same problem? may I know how you figured this out? thnx

    ReplyDelete