菜鸟教程小白 发表于 2022-12-12 19:34:33

ios - 取消操作时未调用 NSOperation dealloc


                                            <p><p>我在我的应用程序中使用 NSOperation。
创建另一个操作时,我正在取消先前执行的操作。但是之前创建的操作的 dealloc 方法在取消该操作时没有调用。</p>

<p>请建议我。
谢谢。 </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我认为您需要的是 isFinished 返回 YES 而 isExecuting 在取消后返回 NO。否则操作对象永远不会被释放。</p>

<p>文件说。</p>

<blockquote>
<p>In addition to simply exiting when an operation is cancelled, it is
also important that you move a cancelled operation to the appropriate
final state. Specifically, if you manage the values for the isFinished
and isExecuting properties yourself (perhaps because you are
implementing a concurrent operation), you must update those variables
accordingly. Specifically, you must change the value returned by
isFinished to YES and the value returned by isExecuting to NO. You
must make these changes even if the operation was cancelled before it
started executing.</p>
</blockquote></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 取消操作时未调用 NSOperation dealloc,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/9493590/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/9493590/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 取消操作时未调用 NSOperation dealloc