Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stopping a performSelector: from being performed

Pretty basic problem.

[self performSelector:@selector(startSequence:) withObject:nil afterDelay:1.0];

However, is there a way to stop this after its been called? Thanks for any help Disco

like image 786
StuStirling Avatar asked Mar 31 '11 09:03

StuStirling


2 Answers

You want +[NSObject cancelPreviousPerformRequestsWithTarget:]. If there are multiple perform requests waiting, this will cancel all of them.

If you want some finer-grained control, you can use +[NSObject cancelPreviousPerformRequestsWithTarget:selector:object:]. Everything matching the predicate is cancelled; if you have multiple identical requests waiting, there's no mechanism to cancel a single one.

like image 183
John Calsbeek Avatar answered Nov 16 '22 03:11

John Calsbeek


There sure is;

[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(startSequence:) object:nil];
like image 27
Roger Avatar answered Nov 16 '22 01:11

Roger