Created
May 24, 2012 03:20
-
-
Save donly/2779238 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// declare | |
@property (retain) NSTimer *unregisteredTimer; | |
// implements | |
- (IBAction)createUnregisteredTimer:sender { | |
NSMethodSignature *methodSignature = [self methodSignatureForSelector:@selector(invocationMethod:)]; | |
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSignature]; | |
[invocation setTarget:self]; | |
[invocation setSelector:@selector(invocationMethod:)]; | |
NSDate *startDate = [NSDate date]; | |
[invocation setArgument:&startDate atIndex:2]; | |
NSTimer *timer = [NSTimer timerWithTimeInterval:0.5 invocation:invocation repeats:YES]; | |
self.unregisteredTimer = timer; | |
} | |
- (IBAction)startUnregisteredTimer:sender { | |
if (unregisteredTimer != nil) { | |
NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; | |
[runLoop addTimer:unregisteredTimer forMode:NSDefaultRunLoopMode]; | |
} | |
} | |
- (IBAction)stopUnregisteredTimer:sender { | |
[unregisteredTimer invalidate]; | |
self.unregisteredTimer = nil; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment