2014-10-30 65 views
1

我使用的核心位置,我的发展目标如下5.0是我的代码开始更新什么是弃用?如何在所有版本中处理它?

self.locationManager = [[CLLocationManager alloc]init]; 
    [self.locationManager setDelegate:self]; 
    [self.locationManager startUpdatingLocation]; 

下面是委托方法

- (void)locationManager:(CLLocationManager *)manager 
    didUpdateToLocation:(CLLocation *)newLocation 
      fromLocation:(CLLocation *)oldLocation 
{ 
    // Do Something Here 
} 

它叫的iOS 5.0和6.0,但在iOS中得到了弃用7.0起 所以适用于iOS 7.0及以上我不得不使用下面

- (void)locationManager:(CLLocationManager *)manager 
    didUpdateLocations:(NSArray *)locations 
{ 
    // Do Something Here 
} 

我的问题是,我将不得不管理两个SE parate委派方法7.0以下和7.0以上的iOS?

如果不是,请详细解释一下。

回答

1

请点击这里阅读本文件 -

为了使这一兼容用iOS 5调用此函数内部新方法

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 

http://www.devfright.com/how-to-make-didupdatelocations-compatible-with-ios-5-and-ios-6/

+0

如何处理不推荐的属性? – 2014-10-30 07:12:36

+1

检查这篇文章 - http://stackoverflow.com/questions/12562152/replacement-for-purpose-property-of-cllocationmanager – 2014-10-30 07:27:12

0

将您的开发目标设置为iOS 5.0。如果是这样的话,这些警告将不会出现。您可以使用已弃用的委托,因为所使用的编译器不知道弃用情况。现在可能会出现这种情况,您需要将此源代码包含在未来的项目中。这些项目可能只支持iOS7及更高版本。如果是这样的话,它总是安全地与代表合作以避免问题。

您也可以关闭使用#pragma警告,就像这样:

// pre-iOS6.0 
#pragma clang diagnostic push 
#pragma clang diagnostic ignored "-Wdeprecated-declarations" 
    [self dismissModalViewControllerAnimated:YES]; 
#pragma clang diagnostic pop 

欲了解更多信息,请查看这篇文章:deprecated warnings in xcode and how to handle deprecation

相关问题