priore

Block execution on main thread

Feb 16th, 2016
621
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