In this scenario, timerFunc() is never called. What am I missing?
class AppDelegate: NSObject, NSApplicationDelegate {
var myTimer: NSTimer? = nil
With swift3, you can run it with,
var timer: Timer?
func startTimer() {
if timer == nil {
timer = Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(self.loop), userInfo: nil, repeats: true)
}
}
func stopTimer() {
if timer != nil {
timer?.invalidate()
timer = nil
}
}
func loop() {
//do something
}