cancelPreviousPerformRequest 与 cancelAllOperations

发布于 2024-09-03 19:43:29 字数 48 浏览 2 评论 0原文

我现在都用,但我不确定哪个更好。到底有什么区别?我知道的模糊问题。为WWDC做准备

i use now both but i'm not sure which is better. what is exactly the difference? fuzzy question i know. preparing for wwdc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雪花飘飘的天空 2024-09-10 19:43:29

向操作队列发送 cancelAllOperations 消息会取消该队列中的所有操作(即,它告诉操作取消),而 cancelPreviousPerformRequestsWithTarget: 告诉目标对象取消之前被告知要执行的所有延迟执行的操作。

这里没有“更好”,只有“更好”。这两种方法没有可比性。一取消 NSOperations;另一个取消延迟执行的请求。您使用哪种取消完全取决于您是否创建了 NSOperation 并将其放入 NSOperationQueue 或发送了延迟执行请求。

Sending a cancelAllOperations message to an operation queue cancels all the operations in that queue (that is, it tells the operations to cancel), whereas cancelPreviousPerformRequestsWithTarget: tells the target object to cancel all delayed performs it had previously been told to do.

There is no “better” here; the two methods are incomparable. One cancels NSOperations; the other cancels delayed-perform requests. Which cancellation you use depends entirely on whether you made an NSOperation and put it an NSOperationQueue or sent a delayed-perform request.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文