import UIKit class ViewController: UIViewController { var time = 0 func result(){ time++ print(time) } override func viewDidLoad() { super.viewDidLoad() var timer = NSTimer() timer = NSTimer.scheduledTimerWithTimeInterval(1,target: self,selector: ("result"),userInfo: nil,repeats: true) }