Is it allowed to call a static method from NSTimer? The compiler will not allow this, complaining about the cryptic "Extra argument" in the call.
struct MyStruct { static func startTimer() { NSTimer.scheduledTimerWithTimeInterval(1.0, target: MyStruct.self, selector: "doStuff", userInfo: nil, repeats: true) } static func doStuff() { println("Doin' it.") } } MyStruct.startTimer()
But of course, this works great ...
class MyClass { func startTimer() { NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "doStuff", userInfo: nil, repeats: true) } func doStuff() { println("Doin' it.") } } var instanceOfClass = MyClass() instanceOfClass.startTimer()
Am I just using the syntax wrong, or is this not allowed?
source share