I’m using NSOperationQueue, and NSOperation for running some function on background click.
But I want to be able, when user clicks some button, stop that Operation.
How can I do it?
Something like, [currentoperation stop];
Cancel – won’t work me. I want to stop immediately.
Thanks
You should be calling the
-cancelmethod, and the operation itself has to support being cancelled by monitoring theisCancelledproperty/keypath and safely stopping when its value becomesYES. If the NSOperation is your own, you will probably have to create a custom subclass to implement this functionality. You cannot (safely) force an arbitrary operation to immediately stop. It has to support being cancelled.