There is an Obj-C file which is included into several projects with different deployment target. This file has following codeline:
[[UIApplication sharedApplication] openURL:url];
When I compile project targeting iOS 10, I get a warning:
'openURL:' is deprecated: first deprecated in iOS 10.0 - Please use openURL:options:completionHandler: instead
I tried to fix it with the following construction:
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
} else {
[[UIApplication sharedApplication] openURL:url];
}
but it still generates the same warning!
I do not want to switch this warning off globally, so what I ended with is monstrous
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[UIApplication sharedApplication] openURL:url];
#pragma clang diagnostic pop
}
So I wonder if I really need to have such an ugly code, or maybe I have missed something, and such situation could have been handled in another (more graceful) manner?