Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timer.scheduledTimer Swift 3 pre-iOS 10 compatibility

I need to schedule a Timer for firing a function every second but I see that in Xcode 8 beta 3 the scheduledTimer is only available for iOS 10.

Is there any alternative for using the timer in iOS 9 or previous versions?

Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { (timer) in print("Hi!")}) 
like image 913
rockdaswift Avatar asked Aug 01 '16 09:08

rockdaswift


1 Answers

Solved using

Timer.scheduledTimer(timeInterval: 1,                            target: self,                          selector: #selector(self.updateTime),                          userInfo: nil,                           repeats: true) 
like image 180
rockdaswift Avatar answered Oct 05 '22 10:10

rockdaswift