Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4014594
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:30:57+00:00 2026-05-20T09:30:57+00:00

I have some model classes which I wanted to store with the CoreData framework.

  • 0

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.

Now I have the following code (it was copied, only the file name was changed to HistoryDataModel):

- (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;
}

Now when I run this code and try to access data in the CoreData I’m getting the following error:

* Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘* -[NSURL initFileURLWithPath:]: nil string parameter’

and it happens when

NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"HistoryDataModel" ofType:@"momd"];

is being executed (the model Path is an empty string).

Any ideas what I might have done wrong?
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:30:57+00:00Added an answer on May 20, 2026 at 9:30 am

    You could try the following snippet, which will save you a lot of time 🙂

    managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];
    

    It returns a model created by merging all the models found in all the bundles (nil parameter). You can set the parameter to a specific array of bundles.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed my little own framework, which depends on some model classes. I
I have some model objects I'm using in my Java client application. Later these
I have a basic model in which i have specified some of the fields
I have a simple ADO.NET Entity Framework 4.0 model (edmx) which defines database tables
In Guvnor global area I have uploaded different jar which contains model classes. After
I have some constants that represent the valid options in one of my model's
I have some configuration data that I'd like to model in code as so:
I have a very interesting problem on my LinqToSql model. On some of my
What are some of the ways you have implemented models in the Zend Framework?
I have some classes in the lib directory, and I want to test it.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.