I am using CoreData and can retrieve my objects using [MyManagedObjectClass findAll]. Now I want to fetch some Data using an NSFetchRequest which looks like this:
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
fetchRequest.entity = [NSEntityDescription entityForName:@"Contacts" inManagedObjectContext:self.context];
fetchRequest.sortDescriptors = [NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"firstName" ascending:YES]];
NSError *error;
NSArray *array = [self.context executeFetchRequest:fetchRequest error:&error];
Although I don’t have a predicate, the request does not return all the objects but 0 objects instead. AFAIK I don’t need to have a predicate, if I want to load all the objects, right?
The problem here was that I was not using the same context as core data. If I get the context from the CoreData object then it works.