【发布时间】:2017-06-13 18:28:20
【问题描述】:
我有一个使用本地通知并支持 iOS 10 的应用程序。我正在尝试添加 iOS 9 支持,这需要我使用旧的位置通知 API。我正在尝试在我的 iOS 10 代码上使用 @available 和 #available,但我不知道如何让我的中心变量仅适用于运行 iOS 10 的设备。
当我将目标从 iOS 10 设置为 9 时,我收到此变量的错误消息:
UNUserNotificationCenter is only available on iOS 10.0 or newer.
它建议我将 @available(iOS 10.0, *) 添加到我不想做的整个课程中,因为此类中的代码将用于 iOS 9。我感谢有关如何将我的 center 属性限制为仅的任何建议iOS 10。
class ViewController: UIViewController, UITextFieldDelegate {
let center = UNUserNotificationCenter.current()
...
}
【问题讨论】:
标签: ios swift uilocalnotification