Skip to content

Instantly share code, notes, and snippets.

@joelmartinez
Created January 23, 2013 21:31
Show Gist options
  • Save joelmartinez/4613721 to your computer and use it in GitHub Desktop.
Save joelmartinez/4613721 to your computer and use it in GitHub Desktop.
A simple category on object to let you perform a block after a delay, rather than having to pass in a selector reference
// http://stackoverflow.com/a/4007066/5416
@implementation NSObject (PerformBlockAfterDelay)
- (void)performBlock:(void (^)(void))block
afterDelay:(NSTimeInterval)delay
{
block = [[block copy] autorelease];
[self performSelector:@selector(fireBlockAfterDelay:)
withObject:block
afterDelay:delay];
}
- (void)fireBlockAfterDelay:(void (^)(void))block {
block();
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment