Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completed shorthand support for aggregate methods by updating shorthand file #107

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/Categories/NSManagedObject+MagicalRecord.h
Original file line number Original file line Diff line number Diff line change
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;
+ (NSArray *) MR_findByAttribute:(NSString *)attribute withValue:(id)searchValue andOrderBy:(NSString *)sortTerm ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context; + (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_inContext:(NSManagedObjectContext *)otherContext;
- (id) MR_inThreadContext; - (id) MR_inThreadContext;
Expand Down
6 changes: 3 additions & 3 deletions Source/Categories/NSManagedObject+MagicalRecord.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ - (id) MR_objectWithMinValueFor:(NSString *)property
return [self MR_objectWithMinValueFor:property inContext:[self managedObjectContext]]; 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 NSExpression *ex = [NSExpression expressionForFunction:function
arguments:[NSArray arrayWithObject:[NSExpression expressionForKeyPath:attributeName]]]; arguments:[NSArray arrayWithObject:[NSExpression expressionForKeyPath:attributeName]]];
Expand All @@ -762,9 +762,9 @@ + (NSNumber *)aggregateOperation:(NSString *)function onAttribute:(NSString *)at
return resultValue; 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 onAttribute:attributeName
withPredicate:predicate withPredicate:predicate
inContext:[NSManagedObjectContext MR_defaultContext]]; inContext:[NSManagedObjectContext MR_defaultContext]];
Expand Down
2 changes: 2 additions & 0 deletions Source/MagicalRecordShorthand.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
+ (NSArray *) findByAttribute:(NSString *)attribute withValue:(id)searchValue inContext:(NSManagedObjectContext *)context; + (NSArray *) findByAttribute:(NSString *)attribute withValue:(id)searchValue inContext:(NSManagedObjectContext *)context;
+ (NSArray *) findByAttribute:(NSString *)attribute withValue:(id)searchValue andOrderBy:(NSString *)sortTerm ascending:(BOOL)ascending; + (NSArray *) findByAttribute:(NSString *)attribute withValue:(id)searchValue andOrderBy:(NSString *)sortTerm ascending:(BOOL)ascending;
+ (NSArray *) findByAttribute:(NSString *)attribute withValue:(id)searchValue andOrderBy:(NSString *)sortTerm ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context; + (NSArray *) findByAttribute:(NSString *)attribute withValue:(id)searchValue andOrderBy:(NSString *)sortTerm ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context;
+ (NSNumber *)aggregateOperation:(NSString *)function onAttribute:(NSString *)attributeName withPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context;
+ (NSNumber *)aggregateOperation:(NSString *)function onAttribute:(NSString *)attributeName withPredicate:(NSPredicate *)predicate;
- (id) inContext:(NSManagedObjectContext *)otherContext; - (id) inContext:(NSManagedObjectContext *)otherContext;
- (id) inThreadContext; - (id) inThreadContext;
+ (void) performFetch:(NSFetchedResultsController *)controller; + (void) performFetch:(NSFetchedResultsController *)controller;
Expand Down