NSOperationQueue中的cancel的小细节

注意点:cancle这个方法不能马上取消当前任务,而只是让isCancle这个标记位为YES;
 
“You cannot directly remove an operation from a queue after it has been added​”
1.在NSOperationQueue中已经添加的任务不能被直接移除;
 
“For operations that are queued but not yet executing, the queue must still call the operation object’s start method so that it can processes the cancellation event and mark itself as finished.”
2.对于还没有执行的任务,队列还是要去调用“start”方法,然后任务才能去完成取消这个动作;
 
“Canceling an operation causes the operation to ignore any dependencies it may have. This behavior makes it possible for the queue to execute the operation’s start method as soon as possible. ”
3.取消任务这个操作会让任务忽略任何一个依赖关系,而快速去执行“start”方法,从而让任务取消;
posted @ 2015-11-23 20:14  军机处  阅读(566)  评论(0)    收藏  举报