Created
October 4, 2012 13:41
-
-
Save lukestringer90/3833592 to your computer and use it in GitHub Desktop.
Macros for NSPredicate and NSSortDescriptor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define pred(format) [NSPredicate predicateWithFormat:format] | |
#define sort(key, asc) [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:key ascending:asc]] | |
//array of core data entities (giggle!) | |
NSArray *entities = (.)(.) | |
//filter array | |
NSArray *filtered = [entities filteredArrayUsingPredicate:pred(@"timestamp != nil")]; | |
//sort array | |
NSArray *sorted = [entities sortedArrayUsingDescriptors:sort(@"timestamp", YES)]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment