NSOperation & NSOperationQueue Cancellation

I encounter some strange problems with some user instances NSOperationqueued in the instance NSOperationQueue:

When I call either [myOperation cancel], or [myOperationQueue cancelAllOperations], the receiver isCancelledfor cancelboolean remains unchanged for my custom subclass instances NSOperation.

I try to cancel operations when the application delegation method is called applicationWillResignActive.

My implementation for the subclass is NSOperationas follows:

  • custom initialization method
  • implemented by main

I have a singleton with strong references to instances of my subclass NSOperationand NSOperationQueue.

In the method of this singleton, I do the following:

myNSOperationQueueInstance = [[NSOperationQueue alloc] init];
myCustomOperation_1 = [MyCustomOperationClass alloc] customInit];
myCustomOperation_2 = [MyCustomOperationClass alloc] customInit];

[myNSOperationQueueInstance addOperations:@[myCustomOperation_1,myCustomOperation_2] waitUntilFinished:NO];

, , .

, singleton applicationWillResignActive, , [myCustomOperation cancel] [myNSOperationQueueInstance cancelAllOperations], isCancelled ( isCancelled ).

, , , NSLog isCancelled, isExecuting, isAsynchronous, NO, isFinished YES, .

, , NSOperationQueue operations, .

cancel setter NSOperation, .

, , , , .

? isCancelled , operations NSOperationQueue , , isFinished boolean YES ?

+4
1

@KenThomases @lead_the_zeppelin (. OP) :

NSOperation Core Data, , , , -main , performBlock ManagedObjectContext, .

, -main , , , , , . , , performBlock: performBlockAndWait:.

. , , , , NSOperation subclass -main.

+1
source

All Articles