Ok ... I solved the problem (I think). As far as I can see, the problem was the βerrorβ of the call.
I made a silly mistake by not initializing the NSError object before the call. So here is what works for me now:
NSError *error = nil; NSArray *storeListArray = [MOC executeFetchRequest:fetchRequest error:&error];
Before that only
NSError *error;
What I found in many examples, by the way. But it looks like this was at least part of the problem.
All my code is as follows:
MyAppDelegate *app = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; NSManagedObjectContext *MOC = [app managedObjectContext]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Store" inManagedObjectContext:MOC]; [fetchRequest setEntity:entity]; NSSortDescriptor *streetDescriptor = [[NSSortDescriptor alloc] initWithKey:@"street" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:streetDescriptor, nil]; [fetchRequest setSortDescriptors:sortDescriptors]; NSError *error = nil; NSArray *storeListArray = [MOC executeFetchRequest:fetchRequest error:&error];
Maybe this helps someone.
source share