Skip to content

Instantly share code, notes, and snippets.

@dictav
Created March 10, 2014 10:13
Show Gist options
  • Save dictav/9462427 to your computer and use it in GitHub Desktop.
Save dictav/9462427 to your computer and use it in GitHub Desktop.
Add [NSOperationQueue addOperationWithBlock:]
@interface NSOperationQueue (Block)
- (void)addOperationWithBlock:(void (^)(void))block;
@end
@implementation NSOperationQueue (Block)
- (void)addOperationWithBlock:(void (^)(void))block
{
NSInvocationOperation *op;
op = [[NSInvocationOperation alloc] initWithTarget:self
selector: @selector(doBlock:)
object: block];
[self addOperation:op];
}
- (void)doBlock:(void (^)(void))block
{
block();
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment