I'm trying to retrieve a list of objects saved using Core Data. No changes where made to the default setup made by Xcode when creating the project. There are items in the actual data store, and the entity Transaction
works fine when saving but when running the following code:
NSManagedObjectContext * context = [[NSApp delegate] managedObjectModel];
NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription * entity = [NSEntityDescription
entityForName:@"Transaction"
inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSError * error = nil;
NSArray * transactionList = [context executeFetchRequest:fetchRequest error:&error];
if (&error != nil) {
[Utility showMessage:error.description asError:YES];
} else {
[Utility showMessage:[NSString stringWithFormat: @"Items: %@", transactionList.count] asError:NO];
}
I receive the following error when trying to create the entity
object.
[NSManagedObjectModel persistentStoreCoordinator]: unrecognized selector sent to instance
What am I missing, or what do I do to check what is causing the error?
Footnotes
- Utility
is a static class which simply generates a NSAlert
box.
- I've been using this tutorial to try and understand how the code works