UPDATE
Here is an easy way to replicate the problem, open any app with a tableview loaded from core data. then in the tab bar, set a different tab to open the same tableview. and you get *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'FooSpelledCorrectly''
I have a second table view in a tabcontroller app, and the app crashes when the tab is selected. I get SIGABRT
I have replicated the (h|m) files of a tableview and added them to the project. In the app delegate I added SearchGroupViewController *searchListController2;
, the original tableview uses SearchDestinationsViewController *searchListController;
I feel I must be missing something simple. Any ideas where else to look? Do I need to create a second controller? Both .m files implement fetchedResultsController
- (NSFetchedResultsController *)fetchedResultsController {
// Set up the fetched results controller if needed.
if (fetchedResultsController == nil) {
// Create the fetch request for the entity.
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// Edit the entity name as appropriate.
NSEntityDescription *entity = [NSEntityDescription entityForName:@"FooSpelledCorrectly" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];
NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@"state" ascending:YES];// was name
NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor1,sortDescriptor2, nil];// was 2// sortDescriptor,
[fetchRequest setSortDescriptors:sortDescriptors];
// Edit the section name key path and cache name if appropriate.
// nil for section name key path means "no sections".
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:@"state" cacheName:nil];//@"state"
aFetchedResultsController.delegate = self;
self.fetchedResultsController = aFetchedResultsController;
//letters = [aFetchedResultsController valueForKey:@"alphabetIndex"];
[aFetchedResultsController release];
[fetchRequest release];
//[sortDescriptor release];
[sortDescriptor1 release];
[sortDescriptor2 release];
[sortDescriptors release];
}
Crash Log:
2011-12-07 13:11:46.367 CoveredBridges[5762:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Recipe''
*** Call stack at first throw:
Thanks for any help or pointers! Robert