Timer.scheduledTimer Swift 3 pre-iOS 10 compatibility

后端 未结 8 2085
我寻月下人不归
我寻月下人不归 2020-12-15 16:31

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 alternat

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-15 17:00

    Solved using

    Timer.scheduledTimer(timeInterval: 1,
                               target: self,
                             selector: #selector(self.updateTime),
                             userInfo: nil,
                              repeats: true)
    

提交回复
热议问题