PageRenderTime 29ms CodeModel.GetById 18ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

/BlocksKit/NSTimer+BlocksKit.m

http://github.com/zwaldowski/BlocksKit
Objective C | 29 lines | 18 code | 7 blank | 4 comment | 0 complexity | 0a9aafbb89fd5b1d16ddef4bddd537fa MD5 | raw file
 1//
 2//  NSTimer+BlocksKit.m
 3//  BlocksKit
 4//
 5
 6#import "NSTimer+BlocksKit.h"
 7
 8@interface NSTimer (BlocksKitPrivate)
 9+ (void)_executeBlockFromTimer:(NSTimer *)aTimer;
10@end
11
12@implementation NSTimer (BlocksKit)
13
14+ (id)scheduledTimerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(BKTimerBlock)block repeats:(BOOL)inRepeats {
15	NSParameterAssert(block);
16	return [self scheduledTimerWithTimeInterval:inTimeInterval target:self selector:@selector(_executeBlockFromTimer:) userInfo:[[block copy] autorelease] repeats:inRepeats];
17}
18
19+ (id)timerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(BKTimerBlock)block repeats:(BOOL)inRepeats {
20	NSParameterAssert(block);
21	return [self timerWithTimeInterval:inTimeInterval target:self selector:@selector(_executeBlockFromTimer:) userInfo:[[block copy] autorelease] repeats:inRepeats];
22}
23
24+ (void)_executeBlockFromTimer:(NSTimer *)aTimer {
25	NSTimeInterval time = [aTimer timeInterval];
26	((BKTimerBlock)aTimer.userInfo)(time);
27}
28
29@end