I create a timer in my ViewDidLoad method of my view-controller.
NSMethodSignature *sgn = [self methodSignatureForSelector:@selector(gameLoop:)];
NSInvocation *inv = [NSInvocation invocationWithMethodSignature: sgn];
[inv setTarget: self];
[inv setSelector:@selector(gameLoop:)];
NSTimer *t = [NSTimer timerWithTimeInterval: 1./30.
invocation:inv
repeats:YES];
NSRunLoop *runner = [NSRunLoop currentRunLoop];
[runner addTimer: t forMode: NSDefaultRunLoopMode];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(statTapped:)
name:@"statTapped"
object:nil];
Who and where can I deallocate this? If i try and do this from my dealloc it wont compile. Since t is not global.
-(void) dealloc
{
if (t)
{
[t invalidate];
[t release];
t=Nil;
}
}
Thanks, Code