// // NSTimer+Blocks.m // // Created by Jiva DeVoe on 1/14/11. // Copyright 2011 Random Ideas, LLC. All rights reserved. // #import "NSTimer+Blocks.h" @implementation NSTimer (Blocks) +(id)scheduledTimerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)())inBlock repeats:(BOOL)inRepeats { void (^block)() = [inBlock copy]; id ret = [self scheduledTimerWithTimeInterval:inTimeInterval target:self selector:@selector(jdExecuteSimpleBlock:) userInfo:block repeats:inRepeats]; // [block release]; return ret; } +(id)timerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)())inBlock repeats:(BOOL)inRepeats { void (^block)() = [inBlock copy]; id ret = [self timerWithTimeInterval:inTimeInterval target:self selector:@selector(jdExecuteSimpleBlock:) userInfo:block repeats:inRepeats]; // [block release]; return ret; } +(void)jdExecuteSimpleBlock:(NSTimer *)inTimer; { if([inTimer userInfo]) { void (^block)() = (void (^)())[inTimer userInfo]; block(); } } @end