简体   繁体   中英

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

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.

肯定有;

[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(startSequence:) object:nil];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM