First, you want to keep a pointer to a timer
self.packetTimer = [NSTimer timerWithTimeInterval:CONNECTION_TIMEOUT target:self selector:@selector(connectionTimeout:) userInfo:nil repeats:NO]; [[NSRunLoop currentRunLoop] addTimer:packetTimer forMode:NSDefaultRunLoopMode];
If you want to cancel it elsewhere in your code, just call:
[self.packetTimer invalidate]; self.packetTimer = nil;
coneybeare Sep 15 '09 at 21:15 2009-09-15 21:15
source share