Skip to content

Instantly share code, notes, and snippets.

@jazzychad
Last active December 20, 2015 10:39
Show Gist options
  • Save jazzychad/6117691 to your computer and use it in GitHub Desktop.
Save jazzychad/6117691 to your computer and use it in GitHub Desktop.
runOnMainQueue
void runOnMainQueue(dispatch_block_t block)
{
if ([NSThread isMainThread]) {
block();
} else {
dispatch_sync(dispatch_get_main_queue(), block);
}
}
@jaykz52
Copy link

jaykz52 commented Jul 30, 2013

way too much code...

void runOnMainQueue(dispatch_block_t block)
{
    // YOLO...
    dispatch_sync(dispatch_get_main_queue(), block);
}

@jazzychad
Copy link
Author

still too much code

void runOnMainQueue(dispatch_block_t block)
{
    // YOLOLOLOLOLOLOLOLO...
    block();
}

@jaykz52
Copy link

jaykz52 commented Jul 30, 2013

I've been out YOLOed. I bow down to the master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment