美文网首页
swift 3.0 定时器Timer

swift 3.0 定时器Timer

作者: 方克己 | 来源:发表于2016-10-11 15:21 被阅读2090次

    各个版本的定时器用法已经写好

    //Swift 3 
    var timer = Timer.scheduledTimer(timeInterval: 0.4, target: self, selector: #selector(self.update), userInfo: nil, repeats: true); 
    //Swift 2.2~2.3 
    var timer = NSTimer.scheduledTimerWithTimeInterval(0.4, target: self, selector: #selector(MyClass.update), userInfo: nil, repeats: true) 
    //Swift <2.2 
    var timer = NSTimer.scheduledTimerWithTimeInterval(0.4, target: self, selector: "update", userInfo: nil, repeats: true)
    

    相关文章

      网友评论

          本文标题:swift 3.0 定时器Timer

          本文链接:https://www.haomeiwen.com/subject/malbyttx.html