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 6776229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:00:10+00:00 2026-05-26T16:00:10+00:00

I have a pre-existing project to which I’ve added Core Data models. I added

  • 0

I have a pre-existing project to which I’ve added Core Data models. I added the Core Data framework, added a data model with entities, and included it in my app’s target, along with some generated NSManagedObject classes. It compiles nicely, and now I’d like to add some tests for the entities I’ve created. Following these instructions, I’ve set up a logic test base class with a setUp method like so:

- (void)setUp {
    model = [NSManagedObjectModel mergedModelFromBundles:nil];
    NSLog(@"model: %@", model);
    coord = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model];
    store = [coord addPersistentStoreWithType:NSInMemoryStoreType
                                configuration:nil
                                          URL:nil
                                      options:nil 
                                        error:NULL];
    ctx = [[NSManagedObjectContext alloc] init];
    [ctx setPersistentStoreCoordinator:coord];
}

This compiles and all the objects are created. However, the model has no entities! The NSLog() output looks like so:

2011-10-29 23:56:58.941 otest[42682:3b03] model: (<NSManagedObjectModel: 0x19c6780>) isEditable 1, entities {
}, fetch request templates {
}

So where are my entities? I’ve poked around the bundle, and there are no .momd files, either. Have I missed some crucial step to get my models to build?

  • 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-26T16:00:11+00:00Added an answer on May 26, 2026 at 4:00 pm

    I did some additional Duck Duck Going and managed to find the information I needed in the this answer. The upshot is that, because a test target doesn’t use a “main” bundle, I have to instantiate the test bundle. So instead of this line:

        model = [NSManagedObjectModel mergedModelFromBundles:nil];
    

    I now have these three lines:

        NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.example.LogicTests"];
        NSURL *url = [bundle URLForResource:@"MyModels" withExtension:@"momd"];
        model = [[NSManagedObjectModel alloc] initWithContentsOfURL:url];
    

    The bundle identifier comes directly from my target build info, while “MyModels” comes from my data model file, which is named “MyModels.xcdatamodeld” and included in the app bundle as “MyModels.momd”. And that, of course, contains my models.

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

Sidebar

Related Questions

How do I handle situations in which I need pre-existing data before the app
I have a couple of pre-existing applications which I need to run in one
I have a .NET Setup Project to which I've added a custom installer action.
I have an image in a userform which displays a pre-existing chart, according the
I have a lot of pre-existing BMPs (and our clients have pre-existing bmps as
I have a project that comprises pre-build Dll modules, built some time in the
I have a form that I pre-populate with test data though jQuery. $('INPUT[name=subscription.FirstName]').val('Jef'); but
I'm creating a Java applet from a large scale pre-existing project (Vizster). I am
I have a lot of pre-existing projects and code in a few different Subversion
i have a well pre-populated sqlite file that i copied into my project (in

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.