Ios 什么是不推荐的?如何在所有版本中处理它?
我使用的核心位置我的发展目标是5.0以下是我的代码开始更新Ios 什么是不推荐的?如何在所有版本中处理它?,ios,objective-c,xcode,gps,core-location,Ios,Objective C,Xcode,Gps,Core Location,我使用的核心位置我的发展目标是5.0以下是我的代码开始更新 self.locationManager = [[CLLocationManager alloc]init]; [self.locationManager setDelegate:self]; [self.locationManager startUpdatingLocation]; 下面是委托方法 - (void)locationManager:(CLLocationManager *)manager
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
}
我的问题是,对于低于7.0和高于7.0的iOS,我是否必须管理两种单独的委托方法
如果没有,请详细解释 将您的开发目标设置为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
有关更多信息,请查看此帖子:请在此处阅读此文档- 要使其与iOS 5兼容,请在此函数中调用该方法的较新版本
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
如何处理弃用房地产?请查看此帖子-