Created
May 28, 2014 00:22
-
-
Save drance/d26278546acfaed54ba1 to your computer and use it in GitHub Desktop.
Run on the main thread. If we're already there, run synchronously.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation NSOperationQueue (BHSAdditions) | |
+ (void)bhs_runOnMainQueue:(void (^)(void))block { | |
NSParameterAssert(block); | |
if ([NSThread isMainThread]) { | |
block(); | |
} else { | |
[[self mainQueue] addOperationWithBlock:block]; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment