AFNetworking/AFIncrementalStore — pull request #181 by alvinhu (2013-04-23 16:52:45+00:00)
Title: app crashes when fetching attribute values by count or sum functions

when fetching attribute values that satisfy a given function such as count, sum etc, the app will crashes with message:
```
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid property ((), name countMember, isOptional 1, isTransient 0, entity Transaction, renamingIdentifier action, validation predicates (
), warnings (
), versionHashModifier (null)
userInfo {
}, attributeType 100 , attributeValueClassName NSNumber, defaultValue 0) passed to setPropertiesToFetch: (entity mismatch)'.
```
The fetching snippet I used looks like below:

NSExpressionDescription *amountDescription = [[NSExpressionDescription alloc] init];
[amountDescription setName:@"amount"];
[amountDescription setExpression:[NSExpression expressionForKeyPath:@"@sum.amount"]];
[amountDescription setExpressionResultType:NSInteger32AttributeType];

NSFetchRequest *fetchTransaction = [NSFetchRequest fetchRequestWithEntityName:@"Transaction"];
[fetchTransaction setPredicate:[NSPredicate predicateWithFormat:@"shopId = %@", shop[@"shopId"]]];
[fetchTransaction setPropertiesToFetch:@[@"action", amountDescription]];
[fetchTransaction setPropertiesToGroupBy:@[@"action"]];
[fetchTransaction setResultType:NSDictionaryResultType];

[_managedObjectContext performBlockAndWait:^{
NSError *error = nil;
NSArray *transactionResults = [_managedObjectContext executeFetchRequest:fetchTransaction error:&error];
if ([transactionResults lastObject]) {
NSLog(@"%@", transactionResults);
}
}];

This fixes the bug by transfer the propertiesToFetch and propertiesToGroupBy from fetchRequest to backingFetchRequest. fetchRequest and backingFetchRequest are in different NSManagedObjectContext.