您知道是否可以 GROUP fetchRequest BY 2个属性的 SUM ?
我已经尝试过:
[request setPropertiesToGroupBy:@[@"senderUserId + receiverUserId"]];
此外:
NSExpression *sumExpr = [NSExpression expressionForFunction:@"add:to:" arguments:[NSArray arrayWithObjects:[NSExpression expressionForKeyPath:@"senderUserId"], [NSExpression expressionForKeyPath:@"receiverUserId"], nil]];
NSExpressionDescription *sum = [[NSExpressionDescription alloc] init];
[sum setName:@"sum"];
[sum setExpression:sumExpr];
[sum setExpressionResultType:NSInteger64AttributeType];
[request setPropertiesToGroupBy:@[sum]];
有什么建议吗? 谢谢!