. , . - .
. , . , .
:
. . - .
, . , kCLErrorNetwork .
@interface MyGeocoderViewController ()
@property (nonatomic, strong) CLGeocoder *geocoder;
@end
@implementation MyGeocoderViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.geocoder = [[CLGeocoder alloc] init];
}
- (void)geocodeAddress:(NSString *)addressString
{
[geocoder geocodeAddressString:addressString
completionHandler:^(NSArray *placemarks, NSError *error) {
if ((placemarks != nil) && (placemarks.count > 0)) {
NSLog(@"Placemark: %@", [placemarks objectAtIndex:0]);
}
else {
UIAlertView *alert = [[UIAlertView alloc] init];
alert.title = @"No places were found.";
[alert addButtonWithTitle:@"OK"];
[alert show];
}
}];
}
@end