Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Persons''*
The entity is created in the data model file and I added the core data functions to the app delegate file.
I am trying to use core data in in my first view controller which is in a tab by doing this:
- (IBAction)save:(id)sender {
NSLog(@"String is %d", [choiceSeg selectedSegmentIndex]);
NSManagedObjectContext *context = self.managedObjectContext;
Persons *person = (Persons *)[NSEntityDescription insertNewObjectForEntityForName:@"Persons" inManagedObjectContext:context];
NSNumber *ageValue = [NSNumber numberWithInt:[choiceSeg selectedSegmentIndex]];
[person setAge:ageValue];
// Save the context
if (![context save:nil]) {
// error checking
}
Also, I did synthesize the managedObjectContext in my view.
What did I do wrong?