So I am trying to get the zip code for a particular location with the MapKit
Framework by following this tutorial. http://www.icodeblog.com/2009/12/22/introduction-to-mapkit-in-iphone-os-3-0-part-2/
In
MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] i开发者_运维百科nitWithCoordinate:coord];
Xcode poses a warning that initWithCoordinate
is deprecated.
Can anyone tell me what I should be doing ?
MKReverseGeocoder can be used as you've written from iOS 3.0 and above, as stated here. Check the beta documentation to see if that's still applicable, if you're developing using the iOS5 beta.
This class is deprecated since iOS 5.0. Use the CLGeocoder class instead.
if you are supporting previous versions of iOS, check for the existence of the CLGeocoder class using
Class geocoder = NSClassFromString(@"CLGeocoder");
if (geocoder != nil){
theGeocoder = [[geocoder alloc]init];
} else {
// use MKReverseGeocoder
}
精彩评论