Skip to content

Instantly share code, notes, and snippets.

@toashd
Last active December 30, 2015 16:38
Show Gist options
  • Select an option

  • Save toashd/7855501 to your computer and use it in GitHub Desktop.

Select an option

Save toashd/7855501 to your computer and use it in GitHub Desktop.
Multithreading and Grand Central Dispatch on iOS (most simple example)
-(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