Assume restroomLocations
is the coordinatesArray
, userLocation
is the user current location, and that you know how to use the CoreLocation
framework to get all users' current location. The following method will help you:
-(NSMutableArray *)getRelevantRestrooms:(NSArray *)restroomLocations withUsersLocation:(CLLocation *)myLocation{
NSMutableArray *resultsArray=[[NSMutableArray alloc]init];
for (CLLocation *location in restroomLocations) {
if ([location distanceFromLocation:myLocation]<=500){
[resultsArray addObject:location];
}
}
return [resultsArray autorelease];
}