NSTimer timerWithTimeInterval: not working

后端 未结 4 1515
挽巷
挽巷 2020-11-28 13:21

I\'ve created a test application with timer before implementing it in my project. It was the first time I\'m using timer. But the issue is when I implemented timer using

4条回答
  •  孤街浪徒
    2020-11-28 13:48

    Also one may want to make sure to add timer on the main thread.

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

提交回复
热议问题