Multithreading and Grand Central Dispatch on iOS

Now I'm trying to understand the concept of gcd. using the grand central dispatcher how to implement multithreading in my application. I have an idea about the gcd concept, but I cannot implement this concept for my application. I need a simple block example to understand multithreading using gcd.please help me ...

+5
source share
2 answers

Good .. The simplest example)

You can write this code in any way. for instance

  -(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");
       });
   });
}
+18
source

Try it, it is very clear and easy - http://en.wikipedia.org/wiki/Grand_Central_Dispatch

+1
source

All Articles