我在我的应用程序中使用 NSOperation。 创建另一个操作时,我正在取消先前执行的操作。但是之前创建的操作的 dealloc 方法在取消该操作时没有调用。
请建议我。 谢谢。
我认为您需要的是 isFinished 返回 YES 而 isExecuting 在取消后返回 NO。否则操作对象永远不会被释放。
文件说。
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.
关于ios - 取消操作时未调用 NSOperation dealloc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9493590/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |