Last active
December 30, 2015 16:38
-
-
Save toashd/7855501 to your computer and use it in GitHub Desktop.
Multithreading and Grand Central Dispatch on iOS (most simple example)
This file contains hidden or 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
| -(void) viewDidLoad { | |
| [super viewDidLoad]; | |
| dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
| //Here your non-main thread. | |
| NSLog (@"Hi, I'm new thread"); | |
| dispatch_async(dispatch_get_main_queue(), ^{ | |
| //Here you returns to main thread. | |
| NSLog (@"Hi, I'm main thread"); | |
| }); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment