我遇到了问题
yld: Symbol not found: _OBJC_CLASS_$_UIUserNotificationSettings
以下是导致应用在 iOS7 设备上运行时出现错误的函数,即使在代码中根本没有调用该函数。
func reigsterForRemoteUserNotifications(notificationTypes: UIUserNotificationType, categories: NSSet) {
let userNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: categories)
(UIApplication.sharedApplication()).registerUserNotificationSettings(userNotificationSettings)
UIApplication.sharedApplication().registerForRemoteNotifications()
}
我不希望在 iOS7 设备上运行时能够访问此方法。我不希望在方法中进行选择检查,因为这意味着该方法可以被使用。我想要的是一个构建配置参数来检查版本: 我无法想出一种方法来编写一个 Swift 等效的预处理器宏来检查正确的 iOS 版本并忽略新的和未声明的 iOS 8 库函数。
#if giOS8OrGreater
// declare the functions that are iOS 8 specific
#else
// declare the functions that are iOS 7 specific
#endif
在文档中,苹果建议使用函数和泛型来替代复杂的宏,但在这种情况下,我需要一个构建配置预编译检查以避免处理未声明的函数。有什么建议吗?在文档中,苹果建议使用函数和泛型来替代复杂的宏,但在这种情况下,我需要一个构建配置预编译检查以避免处理未声明的函数。有什么建议吗?
NSProcessInfo().isOperatingSystemAtLeastVersion(yosemite)
,似乎是在检查操作系统是否为Yosemite。不确定它是否适用于iOS。 - GlennRay