Timer

1. Create property in viewcontroller:
var timer = Timer()
2. In ViewDidLoad:
 self.timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(FirstViewController.tick), userInfo: nil, repeats: true)
//The top means that every 1 second, the function FirstViewController.tick will be repeated
3. Create the function tick, in it, type out what you want to be updated every second, for instance:
TheLabel.text = getCurrentTime()

Comments

Popular posts from this blog

Setting up a playground

Go to another page