停止performSelector:执行 [英] Stopping a performSelector: from being performed
问题描述
非常基本的问题。
[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
推荐答案
您想要 + [ NSObject cancelPreviousPerformRequestsWithTarget:]
。如果有多个执行请求在等待,这将取消所有请求。
You want +[NSObject cancelPreviousPerformRequestsWithTarget:]
. If there are multiple perform requests waiting, this will cancel all of them.
如果你想要一些更细粒度的控制,你可以使用 + [NSObject cancelPreviousPerformRequestsWithTarget:selector:object:]
。与谓词匹配的所有内容都将被取消;如果您有多个相同的请求在等待,则没有机制可以取消单个请求。
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.
这篇关于停止performSelector:执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!