Unfortunately, I think that NSOperationQueue , as the name implies, can only be used as queues, not as stacks. To avoid having to do a whole bunch of manual sorting of tasks, perhaps the easiest task is to process your queues as if they were immutable and mutated by copying. For example.
- (NSOperationQueue *)addOperation:(NSOperation *)operation toHeadOfQueue:(NSOperationQueue *)queue {
It seems that currently freeing a queue that is still working (as is the case with the old operating queue) does not cause it to cancel all operations, but this is not a documented behavior, so it is probably not trustworthy. If you want to be extremely secure, key-value, observe the operationCount property in the old queue and release it when it reaches zero.
Tommy
source share