Skip to content

Instantly share code, notes, and snippets.

@nderkach
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nderkach/cdcb7e0f555ccc9485ec to your computer and use it in GitHub Desktop.
Save nderkach/cdcb7e0f555ccc9485ec to your computer and use it in GitHub Desktop.
https://developers.facebook.com/bugs/757618101026257 PFQueryTableViewController workaround
- (void)objectsDidLoad:(nullable NSError *)error {
[super objectsDidLoad:error];
__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])];
}];
[self setValue:[[self.objects sortedArrayUsingDescriptors:@[distanceDescriptor]] mutableCopy] forKey:@"_mutableObjects"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment