我可以获得使用 PerformSelector:withObject:afterDelay: 延迟的选择器列表吗?
我希望能够单独取消延迟选择器。我可以使用 [NSObject cancelPreviousPerformRequestsWithTarget...]
来完成他的操作,但需要所有方法参数才能执行此操作。当我想取消时,我没有它们。
有没有办法获取延迟的选择器列表以及用于延迟选择器的参数?
当然,解决方法是只跟踪参数。或者使用GCD并让我的选择器(现在是块)检查它们是否应该立即返回。
I would like to be able to cancel delayed selectors individually. I can do his with [NSObject cancelPreviousPerformRequestsWithTarget...]
but need all the method parameters to do this. At the point where I want to cancel, I don't have them.
Is there a way to get the list of selectors that are delayed together with the parameters used to delay the selectors?
The workaround is to just keep track of the parameters, of course. Or to use GCD and make my selectors (now blocks) check to see whether they should immediately return.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不直接。实现此目的的一个简单方法是使用 NSOperation - 然后仅保留对将来可能需要取消的操作的引用。
not directly. an easy way to accomplish this is would use NSOperation - then just hold references to the operations you may need to cancel in the future.