I get this error:
core data data store missing getting error:’NSInvalidArgumentException’,
reason: keypath flowData.flowAmount not found in entity <NSSQLEntity FlowData id=1>
when trying to load data from a core data store into a tableview.
The sqlite database is being re-created the next time I run the app after I remove the app from the Simulator after having changed the data model and reversioned it.
I am able to insert into the database. This dump shows the record I just entered:
INSERT INTO "ZFLOWDATA"
VALUES(1,1,1,NULL,8.0,376884478.384176,376884471.83175,8.0);
However when I try to read from the data store I get the above error.
Here’s the relevant code for when I’m trying to load the data:
- (void)viewDidLoad
{
[super viewDidLoad];
NSError *error;
if (![[self fetchedResultsController] performFetch:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
exit(-1); // Fail
}
self.title = @"Flow Data Items";
}
and
- (NSFetchedResultsController *)fetchedResultsController {
jhsAppDelegate *appDelegate = (jhsAppDelegate *)[[UIApplication sharedApplication]delegate];
managedObjectContext = [appDelegate managedObjectContext];
if (fetchedResultsController != nil) {
return fetchedResultsController;
}
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"FlowData" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];
NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"FlowData.flowAmount"
ascending:NO];
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]];
[fetchRequest setFetchBatchSize:20];
NSFetchedResultsController *theFetchedResultsController =
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:managedObjectContext sectionNameKeyPath:nil
cacheName:@"Root"];
self.fetchedResultsController = theFetchedResultsController;
self.fetchedResultsController.delegate = self;
return fetchedResultsController;
}
and here’s my data model:

and finally, here’s my data model class code for the entity:
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@interface FlowData : NSManagedObject
@property (nonatomic, retain) NSNumber * flowAmount;
@property (nonatomic, retain) NSDate * flowEnteredDateTime;
@property (nonatomic, retain) NSDate * flowOccurrenceDateTime;
@property (nonatomic, retain) NSNumber * flowScheduledFrequencyMinutes;
@property (nonatomic, retain) NSNumber * flowUrgency;
@end
It must be something about how I am trying to read in the data since I am able to insert a row on another viewcontroller because I believe that FlowData.flowAmount does exist on the entity as it is being inserted into the entity.
Any ideas? Does the order in which the attributes are listed in the .h file have to match the order in the actual data model? Do my data types match?
The key for your sortDescriptor should be just
flowAmount.No need to also prepend the entity name.
PS: The order of the properties in the class is irrelevant. Your data types match (
floatandNSNumber).