iPhone - NSTimer not repeating after fire

前端 未结 8 1813
被撕碎了的回忆
被撕碎了的回忆 2021-02-19 16:14

I am creating and firing a NSTimer with:

ncTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
                                           target:sel         


        
8条回答
  •  [愿得一人]
    2021-02-19 16:35

    You could write the same thing in Swift without running in main loops by:

    ncTimer = Timer.scheduledTimer(timeInterval: 1.0, 
                                   target: self, 
                                   selector: #selector(self.handleTimer), 
                                   userInfo: nil, 
                                   repeats: true)
    ncTimer.fire()
    

提交回复
热议问题