Asy*_*nc- 5 xcode notifications swift2 ios10
我正在使用UNUserNotificationCenter实施新通知.但我需要保持向后兼容,因此我在所有地方都进行了检查:
if #available(iOS 10.0, *) { ... }
else { ... }
Run Code Online (Sandbox Code Playgroud)
这似乎在iOS10中运行良好.为了能够使用UNUserNotificationCenter框架,我必须导入:
import NotificationCenter
Run Code Online (Sandbox Code Playgroud)
但它崩溃了iOS9.3,因为它不知道它是什么.它是一个编译时动作,而不是运行时动作 - 所以它意味着我不能在imports上放置条件.如果我创建一个单独的类,并且放
@available(iOS 10.0, *)
class ....
Run Code Online (Sandbox Code Playgroud)
那里的进口也在课堂实施之前发生. 我应该如何解决这个问题?
| 归档时间: |
|
| 查看次数: |
2442 次 |
| 最近记录: |