Created
August 18, 2015 04:31
-
-
Save AmitaiB/839aca3fe226b0ba42bd to your computer and use it in GitHub Desktop.
This file contains 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
-(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