Skip to content

Commit

Permalink
added aggregate methods to the category header and renamed to use MR_…
Browse files Browse the repository at this point in the history
… prefix
  • Loading branch information
duanefields committed Dec 10, 2011
1 parent 8938488 commit aba82b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Source/Categories/NSManagedObject+MagicalRecord.h
Expand Up @@ -99,6 +99,8 @@
+ (NSArray *) MR_findByAttribute:(NSString *)attribute withValue:(id)searchValue andOrderBy:(NSString *)sortTerm ascending:(BOOL)ascending;
+ (NSArray *) MR_findByAttribute:(NSString *)attribute withValue:(id)searchValue andOrderBy:(NSString *)sortTerm ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context;

+ (NSNumber *)MR_aggregateOperation:(NSString *)function onAttribute:(NSString *)attributeName withPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context;
+ (NSNumber *)MR_aggregateOperation:(NSString *)function onAttribute:(NSString *)attributeName withPredicate:(NSPredicate *)predicate;

- (id) MR_inContext:(NSManagedObjectContext *)otherContext;
- (id) MR_inThreadContext;
Expand Down
6 changes: 3 additions & 3 deletions Source/Categories/NSManagedObject+MagicalRecord.m
Expand Up @@ -737,7 +737,7 @@ - (id) MR_objectWithMinValueFor:(NSString *)property
return [self MR_objectWithMinValueFor:property inContext:[self managedObjectContext]];
}

+ (NSNumber *)aggregateOperation:(NSString *)function onAttribute:(NSString *)attributeName withPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context
+ (NSNumber *) MR_aggregateOperation:(NSString *)function onAttribute:(NSString *)attributeName withPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context
{
NSExpression *ex = [NSExpression expressionForFunction:function
arguments:[NSArray arrayWithObject:[NSExpression expressionForKeyPath:attributeName]]];
Expand All @@ -762,9 +762,9 @@ + (NSNumber *)aggregateOperation:(NSString *)function onAttribute:(NSString *)at
return resultValue;
}

+ (NSNumber *)aggregateOperation:(NSString *)function onAttribute:(NSString *)attributeName withPredicate:(NSPredicate *)predicate
+ (NSNumber *) MR_aggregateOperation:(NSString *)function onAttribute:(NSString *)attributeName withPredicate:(NSPredicate *)predicate
{
return [self aggregateOperation:function
return [self MR_aggregateOperation:function
onAttribute:attributeName
withPredicate:predicate
inContext:[NSManagedObjectContext MR_defaultContext]];
Expand Down

0 comments on commit aba82b2

Please sign in to comment.