【发布时间】:2016-04-24 12:46:39
【问题描述】:
我在我的代码中发现了一行不喜欢在 iOS8 上运行,但有一种方法可以在 iOS8 上以不同的逻辑执行相同的任务,这与 iOS9 不同。
我已经使用if #available(iOS 9, *) 在 iOS9 上执行我需要的代码和在 iOS8 上执行代码。但是,在运行时,在对该函数进行几次调用后,iOS9 设备会运行它不应该运行的代码并崩溃。我是否错过了设置if #available(iOS 9, *) 的步骤?
代码如下
if #available(iOS 9, *) {
if(self.otherChats[loc].last?.timestamp! != messageObj.timestamp!){
self.otherChats[loc].append(messageObj)
self.Notfication.postNotificationName(_Chat.Notification.DidGetMessage, object: nil)
}
} else {
self.otherChats[loc].append(messageObj)
self.Notfication.postNotificationName(_Chat.Notification.DidGetMessage, object: nil)
}
【问题讨论】:
标签: ios swift ios8 swift2 ios9