Retain count behavior for NSOperation
-
27-06-2021 - |
Question
Does inserting an NSOperation to a NSOperationQueue increments the retain count of the NSOperation? If YES when will it get decremented?
Solution
Please, read documentation.
- (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
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.