什么是Swift预处理器相当于iOS版本检查比较?
发布时间:2020-12-14 05:42:22 所属栏目:百科 来源:网络整理
导读:我正进入(状态 yld: Symbol not found: _OBJC_CLASS_$_UIUserNotificationSettings 这是在iOS7设备上运行应用程序时导致错误的功能,甚至在代码中完全没有调用该功能. 06001 在iOS7设备上运行时,我根本不希望该方法可以访问.我不想在其中进行选择检查,因为这
我正进入(状态
yld: Symbol not found: _OBJC_CLASS_$_UIUserNotificationSettings 这是在iOS7设备上运行应用程序时导致错误的功能,甚至在代码中完全没有调用该功能.
在iOS7设备上运行时,我根本不希望该方法可以访问.我不想在其中进行选择检查,因为这意味着该方法可用于开始. 我想要的是一个build config参数来检查版本: #if giOS8OrGreater // declare the functions that are iOS 8 specific #else // declare the functions that are iOS 7 specific #endif 在文档中,苹果正在建议函数和泛型代替复杂的宏,但在这种情况下,我需要一个构建配置预编译检查,以避免处理未声明的函数.有什么建议么.
在Constants.swift中:
Swift 1: let Device = UIDevice.currentDevice() private let iosVersion = NSString(string: Device.systemVersion).doubleValue Swift 2: let Device = UIDevice.currentDevice() private let iosVersion = Double(Device.systemVersion) ?? 0 let iOS8 = iosVersion >= 8 let iOS7 = iosVersion >= 7 && iosVersion < 8 然后在其他文件 if iOS8 { } else { } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |