Search code examples
grand-central-dispatchnsoperationnsoperationqueue

Calling dispatch_async(dispatch_get_main_queue() ) inside a NSOperationqueue


I'm performing a few NSInvocationOperations by adding them to a NSOperationQueue. While making changes to UI, I call the dispatch_async(dispatch_get_main_queue() ) instead of [NSOperationQueue mainQueue] addOperationWithBlock:^(void){}]. Does this sound logically right? I'm still trying to execute the block on the main thread.


Solution

  • Right. dispatch_async(dispatch_get_main_queue(), block) is thread-safe, just putting the block to the main queue, so you can call it from NSOperationQueue or any thread.