我不是在发明轮子.在iOS8中,要从应用程序内部打开"设置",我正在使用此代码:
BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL);
if (canOpenSettings)
{
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
Run Code Online (Sandbox Code Playgroud)
代码在stackoverflow中有很多答案和问题.
问题出现在Xcode 6.3上,我有一个警告说:
Comparison of address of 'UIApplicationOpenSettingsURLString' not equal to a null pointer is always true
有趣的是Apple在他们的示例代码中使用它:https:
//developer.apple.com/library/ios/samplecode/AppPrefs/Listings/RootViewController_m.html
关于如何避免警告并仍然检查我是否可以打开设置的一些想法?