Tried this in the playground, but "timer" isn't ever printed. Why isn't the timer firing?
class Tester {
var myTimer:NSTimer?
init() {
print("initialized")
myTimer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "timerFunc:", userInfo: nil, repeats: true)
}
func timerFunc(timer:NSTimer) {
print("timer")
}
}
var test = Tester()
I then tried to have Tester subclass NSObject and got the same results. "initialized" prints, but not "timer". No errors produced either.
class Tester:NSObject {
var myTimer:NSTimer?
override init() {
super.init()
print("initialized")
myTimer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "timerFunc:", userInfo: nil, repeats: true)
}
func timerFunc(timer:NSTimer) {
print("timer")
}
}
var test = Tester()