I would like to use a singleton to manage a NSTimer. This singleton should start/stop a timer and this timer should run a function each time the timer is done.
import Foundation
import CoreData
import UIKit
class TimerManager{
var delegate: TimerManager?
var timer: NSTimer?
static let sharedInstance = TimerManager()
private init(){
timer = NSTimer()
}
func startTimer(){
timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector("countUp"), userInfo: nil, repeats: true)
}
func countUp(){
print("do something...")
}
}
But this is makes an error
*** NSForwarding: warning: object 0x7fa04a42c840 of class 'Ttc.TimerManager' does not implement methodSignatureForSelector: -- trouble ahead Unrecognized selector -[Ttc.TrackingManager countUp]