Using an NSTimer in Swift

前端 未结 10 1514
生来不讨喜
生来不讨喜 2020-12-05 06:19

In this scenario, timerFunc() is never called. What am I missing?

class AppDelegate: NSObject, NSApplicationDelegate {

    var myTimer: NSTimer? = nil

             


        
10条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-05 07:14

    Swift 3.0 syntax for the run loop thingy:

    RunLoop.current.add(myTimer, forMode: .commonModes)
    

提交回复
热议问题