【发布时间】:2016-09-10 15:52:35
【问题描述】:
我有一个将数据发送到 Parse 的按钮操作。按下按钮后,标题变为取消,当按下“取消”按钮时,数据将从 Parse 中删除。我想知道如何在 60 秒后使用 NSTimer 自动取消。我也设置了一个数组(var isCalling = false)
// 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)
}
【问题讨论】: