CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(27.941761 , -82.171537);
MKReverseGeocoder *reverseGeocoder =[[MKReverseGeocoder alloc] initWithCoordinate:coordinate];
NSLog(@"%g",coordinate.latitude);
NSLog(@"%g",coordinate.longitude);
reverseGeocoder.delegate = self;
[reverseGeocoder start];
//????????????????????????????????????????????????????????????????????????
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error{
NSLog(@"MKReverseGeocoder has failed.");
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark{
NSLog(@"current place is :%@",placemark);
}
when i use the Handwritten coordinate, reverseGeocoding failed. but when i use the - coordinate geted from (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation, successed. why?
When I dropped your code into a test project, it worked perfectly fine for me:
Here is what I think is going wrong. You're using ARC and not saving your "
reverseGeocoder
" anywhere (like in an ivar or a property), so as soon as the function where you created "reverseGeocoder
" finishes, ARC releases it.A couple other things:
If there is an error parameter available to you in delegate methods, you should make use of them. Like this:
And lastly & most importantly, "
MKReverseGeocoder
" has been deprecated since iOS 5. There's a good chance it will go away in future versions of iOS. You should try to find a replacement to use for reverse geocoding.