Added find and delete methods that creates a where clause based on a dictionary of attributes and values. #389

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants

With literals being available now for dictionaries it is super handy to do make a query return on a nice clean dictionary of key value pairs. This compliments the existing find/delete by attribute methods. Examples of use:
[SomeClass MR_deleteAllMatchingDictionaryOfAttributesAndValues:@{@"firstName" : @"Gary", @"lastName" : @"Tubbs"}];
NSArray *results = [SomeClass MR_FindAllMatchingDictionaryOfAttributesAndValues:@{@"firstName" : @"Gary", @"lastName" : @"Tubbs"}];

Added:

(NSArray *) MR_FindAllMatchingDictionaryOfAttributesAndValues:(NSDictionary *)attributesAndValues;
(NSArray *) MR_FindAllMatchingDictionaryOfAttributesAndValues:(NSDictionary *)attributesAndValues inContext:(NSManagedObjectContext *)context;
(BOOL) MR_deleteAllMatchingDictionaryOfAttributesAndValues:(NSDictionary *)attributesAndValues inContext:(NSManagedObjectContext *)context;
(BOOL) MR_deleteAllMatchingDictionaryOfAttributesAndValues:(NSDictionary *)attributesAndValues;

paulthorsteinson added some commits Jan 19, 2013

@paulthorsteinson paulthorsteinson Added find and delete methods that creates a where clause based on a …
…dictionary of attributes and values.

With literals being available now for dictionaries it is super handy to do make a query return on a nice clean dictionary of key value pairs.  This compliments the existing find/delete by attribute methods. Examples of use:
[SomeClass MR_deleteAllMatchingDictionaryOfAttributesAndValues:@{@"firstName" : @"Gary", @"lastName" : @"Tubbs"}];
NSArray *results = [SomeClass MR_FindAllMatchingDictionaryOfAttributesAndValues:@{@"firstName" : @"Gary", @"lastName" : @"Tubbs"}];

Added:
+ (NSArray *) MR_FindAllMatchingDictionaryOfAttributesAndValues:(NSDictionary *)attributesAndValues;
+ (NSArray *) MR_FindAllMatchingDictionaryOfAttributesAndValues:(NSDictionary *)attributesAndValues inContext:(NSManagedObjectContext *)context;
+ (BOOL) MR_deleteAllMatchingDictionaryOfAttributesAndValues:(NSDictionary *)attributesAndValues inContext:(NSManagedObjectContext *)context;
+ (BOOL) MR_deleteAllMatchingDictionaryOfAttributesAndValues:(NSDictionary *)attributesAndValues;
65706b9
@paulthorsteinson paulthorsteinson Refactored new find and delete by attribute/value calls
-Made the method names less verbose.
-Corrected the bad camel casing on MR_Find... shame on me for that one!
-Matched parentheses style.
7b9379d

casademora was assigned Apr 21, 2013

Contributor

tonyarnold commented Jan 1, 2014

Sorry for taking a year (!) to get back to this. @casademora and I have been talking and we think that it might be best to create a helper method on NSPredicate that can be passed to the existing add/delete/find/etc methods.

I'll have a look at prototyping something this week.

tonyarnold closed this Oct 20, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment