openURL: deprecated in iOS 10

前端 未结 6 1601
余生分开走
余生分开走 2020-12-01 09:10

Apple with iOS 10 has deprecated openURL: for openURL:option:completionHandler If I have:

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@\         


        
6条回答
  •  误落风尘
    2020-12-01 09:27

    Write like this.

    Handle completionHandler

    UIApplication *application = [UIApplication sharedApplication];
    NSURL *URL = [NSURL URLWithString:@"http://www.google.com"];
    [application openURL:URL options:@{} completionHandler:^(BOOL success) {
        if (success) {
             NSLog(@"Opened url");
        }
    }];
    

    Without handling completionHandler

    [application openURL:URL options:@{} completionHandler:nil];
    

提交回复
热议问题