Invalidate Timer from Function in Swift
问题 I have an app written in Swift with an NSTimer declared in the viewDidLoad ; the timer runs a function once every second. Here's the code inside my viewDidLoad() : let checkStateTimer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "callCheckState:", userInfo: nil, repeats: true) Currently, I have another function which is called which I want to pause the timer. It should, I believe, use: checkStateTimer.invalidate() However, because the timer is in the viewDidLoad and