Last active
October 16, 2015 10:19
-
-
Save nderkach/89da0f8beecdef55b302 to your computer and use it in GitHub Desktop.
Parse with NSSortDescriptor example
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
NSSortDescriptor *commonLikesDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"fblikes" ascending:YES comparator:^NSComparisonResult(NSArray* obj1, NSArray* obj2) { | |
NSMutableSet *intersection1 = [NSMutableSet setWithArray:user[@"fblikes"]]; | |
[intersection1 intersectSet:[NSSet setWithArray:obj1]]; | |
NSMutableSet *intersection2 = [NSMutableSet setWithArray:user[@"fblikes"]]; | |
[intersection2 intersectSet:[NSSet setWithArray:obj2]]; | |
return [@([intersection1 count]) compare:@([intersection2 count])]; | |
}]; | |
__block PFGeoPoint *currentLocation = [PFUser currentUser][@"location"]; | |
NSSortDescriptor *distanceDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"location" ascending:YES comparator:^NSComparisonResult(PFGeoPoint* obj1, PFGeoPoint* obj2) { | |
return [@([currentLocation distanceInMilesTo:obj1]) compare:@([currentLocation distanceInMilesTo:obj2])]; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment