title: +entityForName: could not locate an entity named 'myModel' in this model in core data - what's missing?
body: <p>I'm now building up Core Data based iOS application and when I tried to insert new managed object by executing <code>[NSEntityDescription insertNewObjectForEintityForName:@"myModel" inManagedObjectContext:_managedObjectContext];</code> within <code>AppDelegate.m</code>, I got the error described on the title.</p>
  
  <p>Here's my <code>AppDelegate.h</code> file:</p>
  
  <pre><code>
  #import 
  
  @interface AppDelegate : UIResponder 
  
  @property (strong, nonatomic) UIWindow *window;
  
  @property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
  @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
  @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
  
  - (void)saveContext;
  - (NSURL *)applicationDocumentsDirectory;
  
  // maybe required?
  //@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
  
  @end
  </code></pre>
  
  <p>And here's my <code>AppDelegate.m</code> file (only displaying the relevant part):</p>
  
  <pre><code>
  #import "AppDelegate.h"
  
  #import "MyModel.h"
  #import "listViewController.h"
  
  @implementation AppDelegate
  
  @synthesize managedObjectContext = _managedObjectContext;
  @synthesize managedObjectModel = _managedObjectModel;
  @synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
  
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
      //managed object context settings
      UITabBarController *tabbarController = (UITabBarController *)self.window.rootViewController;
      UINavigationController *navigationController = [[tabbarController viewControllers] objectAtIndex:0];
      listViewController *listcontroller = [[navigationController viewControllers] objectAtIndex:0];
  
      listcontroller.managedObjectContext = self.managedObjectContext;
  
      NSLog(@"%@", _persistentStoreCoordinator.managedObjectModel);
  
  
      MyModel *newMyModel = [NSEntityDescription insertNewObjectForEntityForName:@"MyModel" inManagedObjectContext:_managedObjectContext];
  
      return YES;
  }
  
  </code></pre>
  
  <p>in this application, I want to use tabbar controller as root view controller and when the app starts, I want to navigation controller as the tabbar controller's root view controller, and use tableview controller as the navigation controller's root view controller. And in the table view controller, I want to use Core Data functionality to display a lot of entities to users.</p>
  
  <p>If I used breakpoint at the exact point of the <code>NSLog()</code> output, it didn't return any errors. And when I moved one line forward to output the log message, the following output returns:</p>
  
  <pre><code>
  () isEditable 0, entities {
  }, fetch request templates {
  }
  </code></pre>
  
  <p>which means I don't have entities for some reasons.</p>
  
  <p>So why are there no entities in this situation? From <a href="https://stackoverflow.com/questions/7100302/coredata-error-entityforname-could-not-locate-an-nsmanagedobjectmodel-for-ent">this answer</a> here over SO, I don't misspelled my entity name. Also, my objectModelContext is not set to nil. So did I set the wrong managed object? Am I doing something wrong in the first three lines in <code>didFinishLaunchingWithOptions</code> method?</p>
  
  <p>Or is there something that is causing the issue here? Or what am I missing?</p>
  
  <p>I use iOS 7 and Xcode 5 and I don't have any managed objects in my entity - after all, the error happened when I tried to instantiate those managed objects.</p>
  
  <p>Thanks.</p>