Hi,
My app start to count the seconds when oppened. Follow the code:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var label1: UILabel! //Display showing the seconds
var i = 0 //Counter
override func viewDidLoad() {
super.viewDidLoad()
// After loading the view.
Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(Estouro), userInfo: nil, repeats: true)
}
@objc func Estouro(){
i = i + 1
label1.text = String(i) //Display seconds
}
}
What can I do to keep counting the secounds in background or after lock the screen?
Thank you,