0

lets have one scenario as follows,

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    // Doing some DB operation or Server call

   // After getting result i am making UI update in main thread
   [self performSelectorOnMainThread:@selector(myMethod) withObject:nil waitUntilDone:YES];
});

or

calling perform selector in background from a method like,

- (void)callingWSMethod {
    [self performSelectorInBackground:@selector(myMethod) withObject:nil];
}

- (void)myMethod {
    // Doing some DB operation or Server call

    dispatch_async(dispatch_get_main_queue(), ^{
         // After getting result i am making UI update in main thread
    });
}
  1. Can i combine performSelector and GCD ?

  2. Are the above both types of making background thread and main thread call will give the same result? Thanks.

Surfer
  • 1,370
  • 3
  • 19
  • 34
  • Its not duplicate of Grand Central Dispatch (GCD) vs. performSelector - need a better explanation . Also it didnt give me the answer for my question. I dont know why u guys marked as duplicate. its ok atleast comment the YES or NO ans for my question. – Surfer Apr 13 '16 at 13:22
  • Yes, you can combine the two. If you need a better explanation than the excellent explanations on the linked question, you are going to have to edit this question and clarify what part of the answers to that question don't explain it deeply enough for your purposes. – nhgrif Apr 13 '16 at 23:03

0 Answers0