cancelling queued performSelector:afterDelay calls

[NSObject cancelPreviousPerformRequestsWithTarget:]

or

[NSObject cancelPreviousPerformRequestsWithTarget:selector:object:]

The target is the original object on which performSelector:afterDelay: was called.

For example:

// schedule the selector
[self performSelector:@selector(mySel:) withObject:nil afterDelay:5.0];
// cancel the above call (and any others on self)
[NSObject cancelPreviousPerformRequestsWithTarget:self];

See apple docs, it’s right at the end of the performSelector:withObject:afterDelay: description.

Leave a Comment