Using Swift 3 Stopping a scheduledTimer, Timer continue firing even if timer is nil

后端 未结 4 531
無奈伤痛
無奈伤痛 2021-02-02 07:03

We call startTimer function to start a timer. When we wanted to stop it we call stopTimerTest function but after we called stopTimer function the timerTestAction keeps firing. T

4条回答
  •  长发绾君心
    2021-02-02 07:31

    Check, are you really call stopTimerTest(), because timerTest.invalidate() is correct for stopping timer.

    func stopTimerTest() {
        print("stopTimer")
        timerTest.invalidate()
    }
    

提交回复
热议问题