cancelAllOperations()
doesn't work on the mainQueue (the cancel()
method is not called on the NSOperation
object). Am I missing something?
I have to iterate through all operations and call the cancel()
method to get it work.
I can also confirm that cancelAllOperations does not work on [NSOperationQueue mainQueue] (at least on my iOS 5.0 Simulator). Might be intentionally designed like that since it is a shared instance.
My simple workaround is just to subclass NSOperation or NSBlockOperation without overriding anything and then do something like this:
-(void)cancelMyOperationsInMainQueue {
for (NSOperation* o in [[NSOperationQueue mainQueue] operations]) {
if ([o isKindOfClass:[MyOperation class]]) {
[o cancel];
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With