Created
October 29, 2014 04:08
-
-
Save Sunnyztj/e4338327094ef7ae094b to your computer and use it in GitHub Desktop.
dispatch_async
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The main reason you use the default queue over the main queue is to run tasks in the background. | |
For instance, if I am downloading a file from the internet and I want to update the user on the progress of the download, I will run the download in the priority default queue and update the UI in the main queue asynchronously. | |
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ | |
//Background Thread | |
dispatch_async(dispatch_get_main_queue(), ^(void){ | |
//Run UI Updates | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment