Skip to content

Instantly share code, notes, and snippets.

@AmitaiB
Created August 18, 2015 04:31
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 AmitaiB/839aca3fe226b0ba42bd to your computer and use it in GitHub Desktop.
Save AmitaiB/839aca3fe226b0ba42bd to your computer and use it in GitHub Desktop.
-(void)geocodeMe {
CLGeocoder *geocoder = [CLGeocoder new];
[geocoder geocodeAddressString:@"" completionHandler:^(NSArray *placemarks, NSError *error) {
/**
* deprecated sample error message
*/
if (error)
{
// [self.latitudeTextField setText:@"Not found"];
// [self.longitudeTextField setText:@"Not found"];
//
// UIAlertView *alert =
// [[UIAlertView alloc] initWithTitle:@"Geocoding Error"
// message:error.localizedDescription
// delegate:nil
// cancelButtonTitle:@"OK"
// otherButtonTitles: nil];
//
// [alert show];
/**
* deprecated sample success completion block
*/
if ([placemarks count] > 0) {
// CLPlacemark *placemark = [placemarks lastObject];
//
// NSString *latString =
// [NSString stringWithFormat:@"%f",
// placemark.location.coordinate.latitude];
//
// [self.latitudeTextField setText:latString];
//
// NSString *longString =
// [NSString stringWithFormat:@"%f",
// placemark.location.coordinate.longitude];
//
// [self.longitudeTextField setText:longString];
}
}
}];
[geocoder reverseGeocodeLocation:nil completionHandler:^(NSArray *placemarks, NSError *error) {
//ditto
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment