I want to see that my program knows when the timer is done. I'm using WKInterfaceTimer in Xcode 7 Beta 3 (7A152u). The "Tick Tock" prints to the console while the counter is counting down. But when it reaches 0, "Timer Done" does not print.
@IBOutlet var myTimer: WKInterfaceTimer!
@IBAction func startButton() {
myTimer.start()
myTimer.setDate(NSDate(timeIntervalSinceNow: 4)) // Arbitrary 4 second coundown.
// Impliment an alert.
if myTimer == 0 {
print("Timer Done")
} else {
print("Tick Tock")
}
}
What you did is wrong. After you call
setDate
the timer start counting down. To get info what is actual state of the timer you should instantiateNSTimer
and check when it fires.From Apple's Documentation: