I'm trying to get the View Controller to update while I'm in a loop that calls a function that does tons of Label updates. But the update to the screen doesn't happen until I've finished the loop.
Is there a way to force a UI update before continuing? Something like forcing data to be written to a disk.
code for the button to start the loop is something like this:
while (match.currentInnings == currentInnings)
{
playSingleBall()
if (gameover == true)
{
return
}
}
After playSingleBall, I'd like to force a UI update before continuing.
Thanks.
Call it in Dispatch Queue:
Swift 3.x
DispatchQueue.main.async {
updateYourUI()
}
Swift 2.x
dispatch_async(dispatch_get_main_queue()) {
updateYourUI()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With