Skip to content

Instantly share code, notes, and snippets.

@jlcampana
Created April 12, 2013 10:27
Show Gist options
  • Save jlcampana/5371098 to your computer and use it in GitHub Desktop.
Save jlcampana/5371098 to your computer and use it in GitHub Desktop.
Predicate with block
//create predicate and filter the results
NSPredicate *distancePredicate = [NSPredicate predicateWithBlock:^BOOL(Establishment *a, NSDictionary *binding)
{
CLLocation *myLocation = [[CLLocation alloc] initWithLatitude:[a.latitude doubleValue]
longitude:[a.longitude doubleValue]];
return [location distanceFromLocation:myLocation] <= __distance;
}];
NSArray *resultado = [shops filteredArrayUsingPredicate:distancePredicate];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment