Open Settings warning issue in Xcode 6.3: Comparison of address of 'UIApplicationOpenSettingsURLString' not equal to a null pointer is always true

[亡魂溺海] 提交于 2019-12-01 04:35:39
Gabriel.Massana

SOLVED:

The problem is related with the Deployment Target in the App.

If the Target is 8.0 or above, the comparison will be always true because you are always over 8.0. So we do not need the if verification:

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];

Another option can be:

NSURL *settings = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:settings])
{
    [[UIApplication sharedApplication] openURL:settings];
}

I believe this is because &UIApplicationOpenSettingsURLString is never nil in this version so you can just directly use the following to launch settings:

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!