I will keep on adding NSTimer into run loop. If i didn't get response with in the specified time interval my timer expired method will then i will invalidate my timer.If i got response with in the time interval i am invalidating my timer
expirationTimer = [NSTimer timerWithTimeInterval:20 target:self selector:@selector(timerExpired:) userInfo:nil repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:expirationTimer forMode:NSRunLoopCommonModes];
-(void)timerExpired:(NSTimer*)expired //This will execute only when timer is expired
{
[expired] invalidate];
expired = nil;
}
[expirationTimer invalidate];
expiration = nil;
After invalidating my timer, still my call back is going to TimerExpired method. Any help is appreciated