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

  • SEARCH
  • Home
  • 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 6785773
In Process

The Archive Base Latest Questions

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

My app is just a DB where the user just search some scientifical data.

  • 0

My app is just a DB where the user just search some scientifical data. It is build like this:

-It has to “main” views selecteable by a TabBarViewController.
-The first View is where the user just proceeds to the search query.
-The secon view are just some settings, info and disclaimer information.

I used the second view to pre populate the DB which will be shipped along with the app. Now that it’s populated, I’m going to actually implement the settings, info and so on.

The managedObjectContext is set up in the AppDelegate (applicationDidFinish…), like this:

 firstViewViewController.managedObjectContext = self.managedObjectContext; 
secondViewController.managedObjectContext = self.managedObjectContext;
saveCustom.managedObjectContext = self.managedObjectContext;

self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];

return YES;

The managedObjectContext is declared ans synthesized properly in the secondViewController.

The App, so far, works OK and I can save items in to the DB.

Now, I created a modalView which is called from the firstViewController. I want the user to be able to save custom data. To do that, I duplicated what I’ve done in the seconViewController and I added the corresponding code (or what I think it is) in the AppDelegate (see above).

When I try to save data using the modalVIew, I’m getting the following error.

* Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘+entityForName: could not locate an NSManagedObjectModel for entity name XXX

where XXX is the correct name of my entity.

I know it’s something related to the managedObjectContext not being initialized. But I don’t understand why does it work on the seconViewController and not on the modalViewController.

So, how can I make it work?

I know that importing the AppDelegate to the modalView, although it would work, it’s not a good practise.

Thanks in advance!

Edit:

The code I’m using to save the data is as follows:

-(void)saveDataToCD{

NSString *entityString=[NSString stringWithFormat:@"%@",[arrayAdquiritDelMV objectAtIndex:1]];
NSString *deltaString=[NSString stringWithFormat:@"%@",[arrayAdquiritDelMV objectAtIndex:3]];





    NSManagedObjectContext *context = [self managedObjectContext];

    NSManagedObject *pepe = [NSEntityDescription insertNewObjectForEntityForName:entityString inManagedObjectContext:context];  // aqui un string
    [pepe setValue:assigment.text forKey:@"definition"];
    [pepe setValue:impurity.text forKey:@"impurity"];
    [pepe setValue:[NSNumber numberWithDouble:[delta.text doubleValue]] forKey:deltaString];  //aquí un string


    NSError *error;


    if (![context save:&error]) 
    {
        NSLog(@"Problem saving: %@", [error localizedDescription]);
    }}

Edit #2, here is how I call the modal view:

-(IBAction)saveCustom:(id)sender{

if(saveCustomController == nil)
{
    SaveCustom *viewTwo = [[SaveCustom alloc] initWithNibName:@"SaveCustom" bundle:[NSBundle mainBundle]];
    self.saveCustomController = viewTwo;

    [viewTwo release];
}

[self presentModalViewController:self.saveCustomController animated:YES];

}

  • 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-26T17:10:03+00:00Added an answer on May 26, 2026 at 5:10 pm

    From what you are describing it don’t look like this,but it still worth a try.

    Have you modified your Core-Data model since you’ve launch your application?
    If yes you need to go in your application folder and delete the Core-Data backing file.
    Because it is now out of sync with your model and core data don’t know what to do with it.

    The only doubt I have it’s that I would received that error when I launch my application after a modification, not 2 or 3 views later.


    How do you present that view modally, where do you create it and where do you set the context on that view that you present modally?


    you are forgetting to tell the UIViewController what context to use.

    if(saveCustomController == nil)
    {
    SaveCustom *viewTwo = [[SaveCustom alloc] initWithNibName:@"SaveCustom" bundle:[NSBundle mainBundle]];
    self.saveCustomController = viewTwo;
    
    [viewTwo release];
    }
    
    [self presentModalViewController:self.saveCustomController animated:YES];
    

    You are missing a line like this one

    viewTwo.managedContext = aManagedContext;
    

    When you do it in applicationFinised… your instance don’t exist yet.
    And in Obj-C you can send a message to nil, it will just be ignored, you won’t crash like in other language.

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

Sidebar

Related Questions

I wanted to add user search auto-complete (like Facebook's) to my Rails app on
I am possibly taking over an app that literally just encrypts user passwords by
I need a function that a user can just click a flash app button
i have just created a drum app. The user taps on the individual buttons
Just as on StackOverflow, in my app a User can write Questions and can
I've followed this example: RCP+JavaWS but the app just briefly comes up and goes
For my Grails App i use Searchable Plugin to have an nice google-like Search.
I want to implement a search feature in an iPhone app. Basically, the user
Hey, i've just made an iphone app and i'm getting the user to enter
I spend some days to search solution about this trouble : I have an

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.