调用 ViewDidLoad 后立即使计时器开始计数

Make Timer start counting as soon as ViewDidLoad is called

我是这样在ViewDidLoad中设置Timer的:

let timer = Timer.scheduledTimer(
           timeInterval: 3, target: self, selector: #selector(handleAnimation),
       userInfo: nil, repeats: true)

但是在它触发第一个 handleAnimation 方法之前我需要等待 3 秒。 有没有办法让timer在viewDidLoad函数一执行就触发函数?

立即告诉 fire 的计时器。

let timer = Timer.scheduledTimer(
       timeInterval: 3, target: self, selector: #selector(handleAnimation),
   userInfo: nil, repeats: true)
timer.fire()