2011-08-08 13 views
0

因此,我试图通过遵循本教程获取MapKit框架的特定位置的邮政编码。 http://www.icodeblog.com/2009/12/22/introduction-to-mapkit-in-iphone-os-3-0-part-2/Xcode中的“弃用”警告 - initWithCoordinate

MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:coord]; 

Xcode中提出了一个警告,initWithCoordinate已被弃用。

任何人都可以告诉我该怎么办?

+3

检查文件是否存在,它通常规定哪种方法(S)应改为使用。 – johnnieb

+0

我现在正在检查文档。没有提及替代方法。 – Legolas

+0

@johnnieb - 有趣的是,文档不会显示“initWithCoordinate:”被弃用,并将其显示为“可在iOS 3.0及更高版本中使用”。 [MKReverseGeocoder类参考](http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKReverseGeocoder_Class/Reference/Reference.html%23//apple_ref/doc/uid/TP40008323) –

回答

1

MKReverseGeocoder可以像您在iOS 3.0及以上版本中使用的那样使用,如here所述。如果您使用iOS5测试版进行开发,请查看测试版文档以了解它是否仍然适用。

+0

哦废话。他们是否更改iOS5Beta的'MKReverseGeocoder'文档? – Legolas

+2

与NDA相关的任何内容都不能在NDA下讨论。请前往开发人员网站以获取最新文档。 – Alex

+0

哦废话。得到它了。我找到了替代课。谢啦。 – Legolas

0

此课程自iOS 5.0起弃用。改为使用CLGeocoder类。

如果要支持的iOS之前的版本,请检查CLGeocoder类的使用

Class geocoder = NSClassFromString(@"CLGeocoder"); 
if (geocoder != nil){ 
    theGeocoder = [[geocoder alloc]init]; 
} else { 
    // use MKReverseGeocoder 
}