它说它“在 iOS 5 中已弃用”。
- (void)viewDidLoad {
[super viewDidLoad];
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:self.locationManager.location // You can pass aLocation here instead
completionHandler:^(NSArray *placemarks, NSError *error) {
dispatch_async(dispatch_get_main_queue() , ^ {
// do stuff with placemarks on the main thread
CLPlacemark *place = [placemarks objectAtIndex:0];
NSString *zipString = [place.addressDictionary valueForKey:@"ZIP"];
[self performSelectorInBackground:@selector(showWeatherFor:) withObject:zipString];
}
}
}