编译报错“ is deprecated: first deprecated in iOS 6.0”

我在代码

if (gDelegate && [gDelegate respondsToSelector:@selector(locationManager:didUpdateToLocation:fromLocation:)])

中判断,gDelegate代理响应locationManager:didUpdateToLocation:fromLocation:方法,
于是后面直接调用方法

[gDelegate locationManager:gLocationManager didUpdateToLocation:newLocation fromLocation:oldLocation];

但是在编译时报错

 'locationManager:didUpdateToLocation:fromLocation:' is deprecated: first deprecated in iOS 6.0 [-Werror,-Wdeprecated-declarations] 

 [gDelegate locationManager:gLocationManager didUpdateToLocation:newLocation fromLocation:oldLocation];

不是很清楚解决问题的思路。

这还有啥不清楚的?提示很清楚了,这个方法已经废弃

我是通过 respondsToSelector 判断出 这个代理有locationManager:didUpdateToLocation:fromLocation:代理方法,
然后直接调用他,这个时候编译报错,因为方法废弃,这个意思我知道。

现在用NSInvocation编译过去了。

我还是调用程序以前的代理,他的代理方法里面有这个方法。
但是现在的SDK里面废弃了这个方法,编译不通过,实际上是有实现的,我想问下老大这个可以在编译指令上加参数解决这个问题吗?

google关键词:

iOS compile ignore deprecate

贴一段示例代码,经过测试后这是我最后解决的方法。

    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wcovered-switch-default"
    switch (style) {
        case UITableViewCellStyleDefault:
        case UITableViewCellStyleValue1:
        case UITableViewCellStyleValue2:
        case UITableViewCellStyleSubtitle:
            // ...
        default:
            return;
    }
    #pragma clang diagnostic pop