Block execution on main thread

priore Feb 16th, 2016 529 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static void OnMainThread(dispatch_block_t block)
  2. {
  3.     if (!block)
  4.         return;
  5.     else if ([NSThread isMainThread])
  6.         block();
  7.     else
  8.         dispatch_async(dispatch_get_main_queue(), block);
  9. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand