title: '-[NSURL initFileURLWithPath:]: nil string parameter' when using CoreData
body: <p>I have some model classes which I wanted to store with the CoreData framework. I have created the xcdatamodel file and added these already existing classes to the CoreData model file. I have also copied the code responsible for managing the context, etc. from the core data project template from the XCode.</p>
  
  <p>Now I have the following code (it was copied, only the file name was changed to HistoryDataModel):</p>
  
  <pre><code>- (NSManagedObjectModel *)managedObjectModel {
  
     if (managedObjectModel != nil) {
         return managedObjectModel;
     }
     NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"HistoryDataModel"  ofType:@"momd"];
     NSLog(@"Model path:", modelPath);
     NSURL *modelURL = [NSURL fileURLWithPath:modelPath];
     managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];    
     return managedObjectModel;
  }
  </code></pre>
  
  <p>Now when I run this code and try to access data in the CoreData I'm getting the following error:</p>
  
  <blockquote>
    <p><strong>* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*</strong> -[NSURL initFileURLWithPath:]: nil string parameter'</p>
  </blockquote>
  
  <p>and it happens when </p>
  
  <pre><code>NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"HistoryDataModel" ofType:@"momd"];
  </code></pre>
  
  <p>is being executed (the model Path is an empty string).</p>
  
  <p>Any ideas what I might have done wrong?
  Thanks!</p>