Skip to content

Instantly share code, notes, and snippets.

@brutella
Created November 8, 2013 11:39
Show Gist options
  • Save brutella/7369829 to your computer and use it in GitHub Desktop.
Save brutella/7369829 to your computer and use it in GitHub Desktop.
NSExpression *minExpression = [NSExpression expressionForFunction:@"stddev:" arguments:@[ [NSExpression expressionForKeyPath:@"amount"] ]];
NSString *stdKey = @"std";
NSExpressionDescription *stdExpressionDescription = [[NSExpressionDescription alloc] init];
stdExpressionDescription.name = stdKey;
stdExpressionDescription.expression = minExpression;
stdExpressionDescription.expressionResultType = NSFloatAttributeType;
__block NSDictionary *dictionary = nil;
[context performBlockAndWait:^{
NSFetchRequest *fetchRequest = [...]
fetchRequest.propertiesToFetch = @[ stdExpressionDescription ];
NSError *fetchError = nil;
NSArray *result = [context executeFetchRequest:fetchRequest error:&fetchError];
[...]
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment