正如我有三個時間間隔一個小於15分鐘,比第二個大於或等於15和第三個是大於或等於 30.In我的情況下,只有我檢查一旦conditions.But我要檢查每1 minute.Because條件的特定一個時間間隔所有按鈕的顏色後,我應該改變成appYellowColor()only.Any幫助appreciable.Thanks提前!這是我的代碼。Swift2:反覆檢查的一個時間間隔中的iOS
if NetworkService.weAreOnline(true) && interval/60 < 15 {
print("appYellowColor()")
startButton.backgroundColor = UIColor.appYellowColor()
}
else if NetworkService.weAreOnline(true) && interval/60 >= 15 && interval/60 < 30 {
print("grayColor()")
startButton.backgroundColor = UIColor.grayColor()
startButton.userInteractionEnabled = false
}
else if NetworkService.weAreOnline(true) && interval/60 >= 30 {
print("redColor()")
startButton.backgroundColor = UIColor.redColor()
startButton.userInteractionEnabled = false
}
輪詢在這種情況下是非常糟糕的。考慮使用* NetworkService *,當條件改變時**通知**。 *不要問,告訴* – vadian
斯威夫特2已經死了。更新。 – matt
@Vinathy NVR沒有 –