Skip to content

Instantly share code, notes, and snippets.

@seanhess
Created May 28, 2010 18:33
Show Gist options
  • Save seanhess/417535 to your computer and use it in GitHub Desktop.
Save seanhess/417535 to your computer and use it in GitHub Desktop.
//
// NSBlockOperation.m
// NSOperations
//
// Created by Sean Hess on 5/28/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "NSBlockOperation.h"
@implementation NSBlockOperation
@synthesize block;
-(id)initWithBlock:(EmptyNSOperationBlock)newBlock {
if (([super initWithTarget:self selector:@selector(executeBlock) object:nil])) {
self.block = newBlock;
}
return self;
}
+(id)blockOperationWithBlock:(EmptyNSOperationBlock)block {
return [[[NSBlockOperation alloc] initWithBlock:block] autorelease];
}
// Since we're just using invocation underneath
-(void)executeBlock {
self.block();
}
-(void)dealloc {
[block release];
[super dealloc];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment