swift should timer be used on main thread code example
Example 1: swift + time delay call main thread
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
//Your code
}
Example 2: use timer swift
Timer.scheduledTimer(timeInterval: 1,
target: self,
selector: #selector(YourController.update),
userInfo: nil,
repeats: true)
// @objc selector expected for Timer
@objc func update() {
// do what should happen when timer triggers an event
}