Skip to content

Instantly share code, notes, and snippets.

@dniswhite
Created September 12, 2018 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dniswhite/4062faf7f6791ea2544eb3cec144cc3b to your computer and use it in GitHub Desktop.
Save dniswhite/4062faf7f6791ea2544eb3cec144cc3b to your computer and use it in GitHub Desktop.
create a separate thread in swift and update UI after work is done
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
// do some task(s) on a separate thread from UI
dispatch_async(dispatch_get_main_queue()) {
// update some UI on the UI thread
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment