Created
February 23, 2012 11:43
-
-
Save frr149/1892504 to your computer and use it in GitHub Desktop.
reverse geocoding with CoreLocation
This file contains hidden or 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) addressFromLocation: (CLLocation *) aLocation{ | |
CLGeocoder *geocoder = [[CLGeocoder alloc] init]; | |
self.activity.hidden = NO; | |
[self.activity startAnimating]; | |
self.output.text = @"Ahora lo averiguo. Contactando con Paco Lobatón..."; | |
[geocoder reverseGeocodeLocation:aLocation | |
completionHandler:^(NSArray *placemarks, NSError *error) { | |
if (placemarks && placemarks.count > 0) { | |
CLPlacemark *placemark = [placemarks objectAtIndex:0]; | |
self.output.text = [NSString stringWithFormat:@"%@ %@, %@ %@", | |
[placemark subThoroughfare], | |
[placemark thoroughfare], | |
[placemark locality], | |
[placemark administrativeArea]]; | |
self.background.image = [UIImage imageNamed:@"pacoLobaton.jpg"]; | |
}else{ | |
self.output.text = @"Estás perdido. Llama a Lobatón"; | |
} | |
[self.activity stopAnimating]; | |
NSLog(@"%@", self.output.text); | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment