I’ve used both GCD and performSelectorOnMainThread:waitUntilDone in my apps, and tend to think of them as interchangeable–that is, performSelectorOnMainThread:waitUntilDone is an Obj-C wrapper to the GCD C syntax. I’ve been thinking of these two commands as equivalent:
dispatch_sync(dispatch_get_main_queue(), ^{ [self doit:YES]; });
[self performSelectorOnMainThread:@selector(doit:) withObject:YES waitUntilDone:YES];
Am I incorrect? That is, is there a difference of the performSelector* commands versus the GCD ones? I’ve read a lot of documentation on them, but have yet to see a definitive answer.
performSelectorOnMainThread:does not use GCD to send messages to objects on the main thread.Here’s how the documentation says the method is implemented:
And on
performSelector:target:withObject:order:modes:, the documentation states: