Вопрос

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 the performSelector:withObject:afterDelay: instance method.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top