Skip to content

Instantly share code, notes, and snippets.

@k0nserv
Last active August 29, 2015 14:05
Show Gist options
  • Save k0nserv/30ed0869da1e2d060872 to your computer and use it in GitHub Desktop.
Save k0nserv/30ed0869da1e2d060872 to your computer and use it in GitHub Desktop.
func onMainThread(action: () -> ()) {
dispatch_async(dispatch_get_main_queue(), action)
}
onMainThread {
myView.hidden = true
}
func inBackground(action: () -> ()) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), action)
}
inBackground {
fetchDataFromInternet()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment