Possible Duplicate:
cancelling queued performSelector:afterDelay calls
I have code to delay displaying my result by 6 seconds. However, I want to be able to abort this delay if the user continues on. I'm not sure how I can cancel the delay method call once it's started. Can someone please point me in the right direction?
This is the code I use to call the delay method and the method below.
[self performSelector:@selector(delay) withObject:nil afterDelay:6.0];
-(void)delay{
[buttonScreen setFont:[UIFont systemFontOfSize:32.0]];
buttonScreen.text = [formatter stringFromNumber:[NSNumber numberWithDouble:result]];
}
performSelector:withObject:afterDelay:
is in the NSObject class documentation. So the thing to do is look in the NSObject class documentation to see what else is there. If you do, you'll see this:
cancelPreviousPerformRequestsWithTarget:
Cancels perform requests previously registered with theperformSelector:withObject:afterDelay:
instance method.