您的位置:首页 > 其它

Xcode9学习笔记78 - 使用Timer执行定时任务

2017-12-02 07:24 411 查看
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(ViewController.timerAction(_:)), userInfo: "Apple", repeats: true)
}

@objc func timerAction(_ timer:Timer) {
let parameter = timer.userInfo
print("I am eating \(parameter!).")
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: