Question

Does inserting an NSOperation to a NSOperationQueue increments the retain count of the NSOperation? If YES when will it get decremented?

Was it helpful?

Solution

Please, read documentation.

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperationQueue_class/Reference/Reference.html

  • (void)addOperation:(NSOperation *)operation

Parameters

operation

The operation object to be added to the queue. In memory-managed applications, this object is retained by the operation queue. In garbage-collected applications, the queue strongly references the operation object.

Discussion

Once added, the specified operation remains in the queue until it finishes executing.

OTHER TIPS

From the documentation :

In memory-managed applications, this object is retained by the operation queue. In garbage-collected applications, the queue strongly references the operation object.

It wil be decremented when dequeued and processed, so you don't have to worry about it. Just add it to the queue and make sure you have balanced all your retain and release, and it will not leak memory.

from documentation

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperationQueue_class/Reference/Reference.html

Parameters.

operation. The operation object to be added to the queue. In memory-managed applications, this object is retained by the operation queue. In garbage-collected applications, the queue strongly references the operation object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top