0
我有一個將數據發送給Parse的按鈕操作。一旦按下按鈕,標題將變爲取消,當按下「取消」按鈕時,數據將從Parse中刪除。我想知道如何在60秒後用NSTimer自動取消。我有一個數組設置太(VAR isCalling = FALSE)如何在60秒後取消NSTimer?
// Function called by within NSTimer in button action
func refresh(){
self.callButtonTapped(nil)
!isCalling
}
// Within the button action
if error == nil {
//Success
self.isCalling = true
self.callButton.setTitle("Cancel", forState: UIControlState.Normal)
self.timer = NSTimer(timeInterval: 60.0, target: self, selector: #selector (self.refresh), userInfo: nil, repeats: false)
}
它現在有效。謝謝! –