func countDownForGetVerify(sender: NSTimer) {
verifyBtn.setTitle("(\(Int(kVerityTime))s)", forState: .Disabled)
kVerityTime--
if kVerityTime == 0 {
stopCountDown()
}
}
private func startCountDown() {
timer.fireDate = NSDate.distantPast()
}
private func stopCountDown() {
kVerityTime = 60
timer.fireDate = NSDate.distantFuture()
verifyBtn.enabled = true
}
// MARK: - Lazy initial
private var timer: NSTimer {
get {
return NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "countDownForGetVerify", userInfo: nil, repeats: true)
}
}
答案 0 :(得分:4)
因为缺少尾随冒号(代表参数)
"countDownForGetVerify:"
答案 1 :(得分:-1)
每当你写任何选择器时,总是在末尾指定冒号 所以替换这一行
"NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "countDownForGetVerify", userInfo: nil, repeats: true)
用这个
NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "countDownForGetVerify:", userInfo: nil, repeats: true)