gpt4 book ai didi

iphone - 更改 NSOperation 优先级的安全方法

转载 作者:行者123 更新时间:2023-12-03 16:08:32 28 4
gpt4 key购买 nike

是否有一种安全的方法来更改已在 NSOperationQueue 中排队的 NSOperation 的优先级?如果操作尚未开始,则没有问题,但如果它已经执行,我会收到 NSInvalidArgumentException。

最佳答案

一旦 NSOperation 入队,您就不应该对其进行更改。根据苹果Threading Programming Guide :

Important: You should never modify an operation object after it has been added to a queue. While waiting in a queue, the operation could execute at any time. Changing its status while it is executing could have adverse effects. You can use the methods of the operation object to determine if the operation is running, waiting to run, or already finished.

关于iphone - 更改 NSOperation 优先级的安全方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1146275/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com