我不是在发明轮子。在 iOS8 中,要从应用程序内部打开设置,我使用以下代码:
BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL);
if (canOpenSettings)
{
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
该代码在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
关于如何避免警告并仍在检查我是否可以打开设置的一些想法?