I want to use an NSTimer in a class that doesn't inherit from UIViewVontroller. I have 2 files : a ViewController and a TimerClass like that :
ViewController:
import UIKit
class ViewController: UIViewController {
var timerClass = TimerClass()
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(animated: Bool) {
timerClass.launchTimer()
}
}
TimerClass :
import Foundation
class TimerClass {
var timer = NSTimer()
init(){}
func launchTimer(){
var timer = NSTimer.scheduledTimerWithTimeInterval(2, target: self, selector: "timerEnd", userInfo: nil, repeats: true)
}
func timerEnd(){
println("That worked")
}
}
When I launch that app, I have a crash with :
2015-01-12 19:48:24.322 Timer_TEST[5829:185651] *** NSForwarding: warning: object 0x7fbc3be20710 of class 'Timer_TEST.TimerClass' does not implement methodSignatureForSelector: -- trouble ahead Unrecognized selector -[Timer_TEST.supportFile timerEnd]
Any idea?
Thank you