I'm using a framework that is written in-house and when I try to reduce the amount of warnings I have there is one that comes up constantly, which is 'Implementing depreciated method'. the method in question is openURL
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
When I go to the Framework code I can see where it is depreciated and a suggested change
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(nullable NSString *)sourceApplication annotation:(id)annotation NS_DEPRECATED_IOS(4_2, 9_0, "Please use application:openURL:options:") __TVOS_PROHIBITED;
The suggestion is to use openURL:options. Looking at the documentation for openURL it says I should use like the following
UIApplication *application = [UIApplication sharedApplication];
[application openURL:URL options:@{} completionHandler:nil];
However, this doesn't work, I cannot separate the parameter openURL from the method as it states above when my method looks like this
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
..
}
How do I implement the new suggested change into my existing method call as above?
The method that you need to implement is application:openURL:options:
instead of deprecated one application:openURL:sourceApplication:annotation:
. So replace your method with below one
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
//Your code ..
}
Note :- The instance method openURL:options:completionHandler:
that you are trying to use is used to open the resource at the specified URL asynchronously.