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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:42:03+00:00 2026-05-28T07:42:03+00:00

My application has multiple view controllers. In my VehicleListController I am saving the data

  • 0

My application has multiple view controllers. In my VehicleListController I am saving the data to core data. And in FavouritesController I am fetching the data from core data to display it in table view.

I am getting this error while checking the favouritesController table to view the core data.

'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Favouritesdata''

Entity Name is Favouritesdata.

In application delegate method didFinishLaunchingWithOptions is as

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *user = [defaults objectForKey:@"Username"];
NSString *passwd = [defaults objectForKey:@"Password"];

if ((user != nil) && (passwd != nil)) {

    NSLog(@"Data found");

    self.progressView = [[Progressbar alloc] initWithNibName:@"Progressbar" bundle:nil];
    self.window.rootViewController = self.progressView;
    [self.window makeKeyAndVisible];

}
else {

    NSLog(@"No data saved");

    self.viewController = [[VektorViewController alloc] initWithNibName:@"VektorViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
}

return YES;}

In favouritesController.m to fetch the data

-(void)getData {

NSEntityDescription *entity = [NSEntityDescription entityForName:@"Favouritesdata" inManagedObjectContext:context];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setFetchBatchSize:20];
[request setEntity:entity];
NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"licensePlate" ascending:YES];
NSArray *newArray = [NSArray arrayWithObject:sort];
[request setSortDescriptors:newArray];
NSError *error;
NSMutableArray *results = [[context executeFetchRequest:request error:&error] mutableCopy];
[self setLicensePlateArray:results];
[self.favouritesTable reloadData];
}

And in cellForRowAtIndexPath in favouritesController

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";  

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {

    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

    UILongPressGestureRecognizer *pressRecongnizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(tableCellPressed:)];
    pressRecongnizer.minimumPressDuration = 0.5f;
    [cell addGestureRecognizer:pressRecongnizer];
    [pressRecongnizer release];
}

Favouritesdata *favdata = [licensePlateArray objectAtIndex:indexPath.row];

NSLog(@"favdata: %@", favData);

if ([tableView isEqual:self.searchDisplayController.searchResultsTableView]){
    cell.textLabel.text = 
    [self.filteredListItems objectAtIndex:indexPath.row];
}
else{
    cell.textLabel.text = [favdata licenseplate];
   // [self.licensePlateArray objectAtIndex:indexPath.row];
}

return cell;}

Core data accessors in application delegate.m:

- (NSManagedObjectContext *) managedObjectContext {
if (managedObjectContext != nil) {
    return managedObjectContext;
}
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
if (coordinator != nil) {
    managedObjectContext = [[NSManagedObjectContext alloc] init];
    [managedObjectContext setPersistentStoreCoordinator: coordinator];
}

return managedObjectContext;}

- (NSManagedObjectModel *)managedObjectModel {
if (managedObjectModel != nil) {
    return managedObjectModel;
}
managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];

return managedObjectModel;}

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (persistentStoreCoordinator != nil) {
    return persistentStoreCoordinator;
}
NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory]
                                           stringByAppendingPathComponent: @"LoginTest.sqlite"]];
NSError *error = nil;
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc]
                              initWithManagedObjectModel:[self managedObjectModel]];
if(![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
                                             configuration:nil URL:storeUrl options:nil error:&error]) {
    /*Error for store creation should be handled in here*/
}

return persistentStoreCoordinator;}

- (NSString *)applicationDocumentsDirectory {
return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];}

I have added core data to an existing project. Now I don’t know why I am getting this error while I think I have copied the all required methods and framework to my project.

Can anyone tell me please ?

  • 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-28T07:42:04+00:00Added an answer on May 28, 2026 at 7:42 am

    The error message is pretty clear : there is no instance of NSManagedObjectModel around.

    I used Core Data in only one project and I don’t know if this is a universally acclaimed way to do this, but I set up the various Core Data related objects in the application delegate, and then pass the managed object context around to every controller who needs it.

    But anyway, Core Data is a bit complicated at first. Try and read some stuff about it.

    If it can help you, this is how I did it.

    - (NSManagedObjectModel*) managedObjectModel
    {
        if(!_managedObjectModel)
        {
            NSString* modelPath = [[NSBundle mainBundle] pathForResource:@"Model" 
                                                                  ofType:@"momd"];
            NSURL* modelURL = [NSURL fileURLWithPath:modelPath];
            _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
        }
    
        return _managedObjectModel;
    }
    
    - (NSPersistentStoreCoordinator*) persistentStoreCoordinator
    {
        if(!_persistentStoreCoordinator)
        {
            NSError* error = nil;
            NSURL* storeURL = [NSURL fileURLWithPath:self.dataStorePath];
            NSDictionary* options = [NSDictionary dictionaryWithObjectsAndKeys:
                                     [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
                                     [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
    
            _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] 
                                           initWithManagedObjectModel:self.managedObjectModel];
    
            if(![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType 
                                                          configuration:nil 
                                                                    URL:storeURL 
                                                                options:options
                                                                  error:&error]) 
            {
                #warning handle core data error
                NSLog(@"Error adding persistent store %@, %@", error, error.userInfo);
                abort();
            }
        }
    
        return _persistentStoreCoordinator;
    }
    
    - (NSManagedObjectContext*) managedObjectContext
    {
        if(!_managedObjectContext)
        {
            NSPersistentStoreCoordinator* coordinator = self.persistentStoreCoordinator;
    
            if(coordinator)
            {
                _managedObjectContext = [[NSManagedObjectContext alloc] init];
                [_managedObjectContext setPersistentStoreCoordinator:coordinator];
            }
        }
    
        return _managedObjectContext;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that has multiple states, with each state responding to input
In an application that has multiple webviews, is there any way to have the
I have a TreeView control in my WinForms .NET application that has multiple levels
Hi Sitepoint wizard people, Say we have an admin application that has multiple users
I have a Flex3 application which has to be capable of uploading multiple files
I'm building an application with multiple server involved. (4 servers where each one has
I have an application with multiple forms, each form has the same icon, so
My application has a need to let the user choose a date from a
I have a basic ASP.Net MVC 3 application which has a number of controllers
I want to have one model & view that is served by multiple controllers

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.