I am quite new to Core Data, and actually Objective-C as a whole, so I hope I am phrasing this correctly, I have been able to store and retrieve data using Core Data, but I am struggling to loop through a result set,
// read the data
NSFetchRequest *req = [[NSFetchRequest alloc]init];
[req setEntity:[NSEntityDescription entityForName:@"Card" inManagedObjectContext:app.managedObjectContext]];
//[req setPredicate:[NSPredicate predicateWithFormat:@"cardID == %@", @"1"]];
NSArray *crd = [[app.managedObjectContext executeFetchRequest:req error:nil] lastObject];
for(Card *card in crd){
NSLog(@"%@",card.backImageURL);
}
I keep getting this error though when I try to run the app,
2012-10-16 11:37:29.407 Core test[925:17903] -[Card countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x962f5c0
2012-10-16 11:37:29.408 Core test[925:17903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Card countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x962f5c0'
I am sure it is something extremely simple but for some reason I can’t seem to pinpoint the problem.
Instead of
it should be
If you are getting error, then you should use that error parameter –