gpt4 book ai didi

ios - 队列中的所有操作完成后立即释放 NSOperationQueue

转载 作者:行者123 更新时间:2023-11-29 00:43:02 24 4
gpt4 key购买 nike

我想在所有正在进行的操作都执行完毕后释放 NSOperationQueue。到目前为止,我已经在下面编写了代码,但据我所知,waitUntilAllOperationsAreFinished 是异步调用,无法阻止我的 operationQueue 变为 nil。

- (void)deallocOperationQueue
{
[operationQueue waitUntilAllOperationsAreFinished];
operationQueue = nil;
}

最佳答案

引用 Avi

You don't need to wait for all operations to finish. Just set operationQueue to nil when you're done with it. If the queue still has operations, nothing happens to them; they will still complete.

- (void)deallocOperationQueue
{
operationQueue = nil;
}

我已经测试了代码并确认所述行为确实发生了。

关于ios - 队列中的所有操作完成后立即释放 NSOperationQueue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39015637/

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