位置解析需要用到的类是:CLGeocoder 解析的方法一般是:
- (void)reverseGeocodeLocation:(CLLocation *)location completionHandler: 该方法需要两个参数,第一个参数是CLLocation对象的位置参数,第二个参数是一个包含两个参数的block。
具体的方法调用为:
‘(CLGeocodoCompletionHandler)completionHandler;
CLGeocoder geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:self.currentLocation
completionHandler:^(NSArray *placemarks, NSError *error){
if (error) {
NSLog(@”%@”, error.description);
}else {
if ([placemarks count] > 0) {
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSString result = placemark.country;
}
}}];`