Closed michaelkirk closed 9 years ago
I have a protocol for this in LJS:
Example
- (void) startAndRetainRepeatingTimers {
[self stopAndReleaseRepeatingTimers];
_timer = [NSTimer scheduledTimerWithTimeInterval:0.2
target:self
selector:@selector(handleRepeatingTimerEvent:)
userInfo:nil
repeats:YES];
}
- (void) stopAndReleaseRepeatingTimers {
if (_timer != nil) {
[_timer invalidate];
_timer = nil;
}
}
done with #50. Thanks for the advice @jmoody!
per @jmoody's advice, invalidate recurring timers so that their target can be GC'd.
See more: http://antonholmquist.com/blog/why-you-really-shouldnt-create-repeating-nstimers-in-init-or-viewdidload/