Reputation: 292
I have a good amount of calculation codes get executed when the UIButton is pressed. But when the button is pressed, the whole view just get stuck and the button stay highlighted until the calculation finished. For example, I set a loading view .hidden = false when the button is pressed too, but the loading view just doesn't show up during the calculation.
Is there any way to fix this?
Thanks in advance!
Upvotes: 0
Views: 85
Reputation: 3588
You should have to do the things in background from the updates you want to run on the UI:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
// do your task
dispatch_async(dispatch_get_main_queue()) {
// update some UI
}
}
Upvotes: 3