I am in Xcode 10.3. I try to use the provided Timer.scheduledTimer
. When it comes to the selector
, Xcode suggests that I should use @objc func
. Is there a better way to do that? perhaps with Swift?
func startTimer() {
countdownTimer = Timer.scheduledTimer( timeInterval: 1,
target: self,
selector: #selector(updateTime),
userInfo: nil, repeats: true)
}
@objc func updateTime() {
//do something
}
(Here explains very well what is a selector: Timer, #selector explanation My question is if it is possible now (August 2019) to do that in a better way
Here it explains how to use Timer: How can I use Timer (formerly NSTimer) in Swift? But this question is older than 5 years. If I understand, In that moment #selector(updateTime) was the best solution. My question is if now, August 2019, there is a new simpler way without @objc )