diff options
Diffstat (limited to 'VKPC/NSTimer+Blocks.m')
-rw-r--r-- | VKPC/NSTimer+Blocks.m | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/VKPC/NSTimer+Blocks.m b/VKPC/NSTimer+Blocks.m new file mode 100644 index 0000000..eec2a59 --- /dev/null +++ b/VKPC/NSTimer+Blocks.m @@ -0,0 +1,37 @@ +// +// 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 |