Created
May 28, 2010 18:33
-
-
Save seanhess/417535 to your computer and use it in GitHub Desktop.
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
// | |
// 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