停止performSelector:执行 [英] Stopping a performSelector: from being performed

查看:115
本文介绍了停止performSelector:执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

非常基本的问题。

[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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆