I was looking at following code.
It's obvious this while loop will cause the user interface to go unresponsive as it is on the main thread of a stopwatch app. What astonishes me though is the label is never updated once. Is this because I never quit the while loop, hence never exit the IBAction method and the GUI is only updated upon exiting the startButton method?
Once again my gratitude!
Code:
@IBAction func startButtonTapped(_ sender: UIButton) {
stopwatch.start()
while stopwatch.isRunning {
print("Updating \(stopwatch.elapsedTime)")
elapsedTimeLabel.text = "\(stopwatch.elapsedTime)"
}
}
It's obvious this while loop will cause the user interface to go unresponsive as it is on the main thread of a stopwatch app. What astonishes me though is the label is never updated once. Is this because I never quit the while loop, hence never exit the IBAction method and the GUI is only updated upon exiting the startButton method?
Once again my gratitude!