Code Block override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) for percent in 1...10 { print(percent) self.accuracyLabel.text = "\(percent)" + "%" sleep(UInt32(0.9)) } } @IBOutlet weak var accuracyLabel: UILabel!
Hi,
I have 2 problems with this code:
1) sleep(UInt32(1.0)) correctly prints 'percent' every 1 second.
But as soon as I go under 1.0, such as sleep(UInt32(0.9)), the print don't happen every 0.9 seconds, but instantly. Why is that?
2) @IBOutlet weak var accuracyLabel: UILabel! text is not updated on each iteration, but only after entire loop has completed. This is not what I would have expected, I would have expected update on each iteration, why is it not the case?
regards,
Brak