在一个 operation 进入队列前不可被取消,也就是说:在 [NSOperation start] 被调用之前,[NSOperation isCancelled] 函数的返回值不能是YES。如果在 operation 进入队列之前被取消了,就不应该再进入队列,否则会阻塞该队列中后续 operation 的执行。同时会在控抽控制台输出错误信息:
NSOperation 0x719bc60 went isFinished=YES without being started by the queue it is in |
如果有这种情况出现的话,在 operation 进入队列之前,就应该检查一下 operation 是否已取消了,如果已取消就不要再进入队列。