Skip to content

Instantly share code, notes, and snippets.

@CastIrony
Created May 7, 2010 23:41
Show Gist options
  • Save CastIrony/394145 to your computer and use it in GitHub Desktop.
Save CastIrony/394145 to your computer and use it in GitHub Desktop.
typedef void(^simpleBlock)(void);
@interface NSObject (Blocks)
-(void)invokeBlock;
@end
#import "NSObject+Blocks.h"
@implementation NSObject (Blocks)
-(void)invokeBlock
{
simpleBlock blockToInvoke = (id)self;
blockToInvoke();
}
@end
#import "NSObject+Blocks.h"
@interface NSTimer (Blocks)
+(NSTimer*)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds repeats:(BOOL)repeats block:(simpleBlock)block;
@end
#import "NSTimer+Blocks.h"
@interface NSTimer (Blocks)
+(NSTimer*)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds repeats:(BOOL)repeats block:(simpleBlock)block
{
return [NSTimer scheduledTimerWithTimeInterval:seconds target:block selector:@selector(invokeBlock) repeats:NO];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment