The Timer should start a function each second. I wrote this, assuming that the timer is started when the program gets started. Where is the error?
override func viewDidLoad() {
super.viewDidLoad()
myTimer.invalidate()
myTimer = Timer(timeInterval: 1, target: self, selector: #selector(startAnimation), userInfo: nil, repeats: true)
}
@objc func startAnimation(){
print("Started")
}
}
You created a timer. But you never started it going (also called scheduling the timer). So nothing happens.
If you wanted to create and start the timer in one move, you should have called https://developer.apple.com/documentation/foundation/timer/1412416-scheduledtimer