Pierre Bernard

My little hideout on the net

NSObject (HHBlockPerform): delayed block executions

typedef void (^HHPerformBlock)(id owner);


@interface NSObject (HHBlockPerform)

- (
void)performAfterDelay:(NSTimeInterval)delay block:(HHPerformBlock)block;

@end


@implementation
NSObject (HHBlockPerform)

- (
void)performAfterDelay:(NSTimeInterval)delay block:(HHPerformBlock)block
{
[
self performSelector:@selector(runBlock:) withObject:[block copy] afterDelay:delay];
}

- (
void)runBlock:(HHPerformBlock)block
{
block(
self);

[block
release];
}

@end
Comments (1)