Reputation: 4935
I want to execute a function before an NSOperation is cancelled. In main
function, I add below code to achieve this goal:
if (self.isCancelled) {
[self doSomething];
return;
}
But if I cancel an operation before its start method is called, where should I call doSomething
?
For queued operations, it simply marks the operation as ready to execute and lets the queue call its start method, which subsequently exits and results in the clearing of the operation from the queue.
According to above Apple's document, I know that I can call doSomething
in start
function, so am I right?
- (void)start {
if (self.isCancelled) {
[self doSomething];
}
[super start];
}
Upvotes: 0
Views: 215