Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does dispatching to a queue that's owned by an object retain that object? [duplicate]

Suppose I have a simple call dispatch_async(self.queue, ^{ /* Empty */ }), where self.queue is a queue created previously.

Does self get retained by the Block in this case, given that there is no self reference inside the block, but only as a parameter for dispatch_async()?

like image 556
peetonn Avatar asked Nov 02 '22 19:11

peetonn


1 Answers

Ok, so apple docs states that

The queue is retained by the system until the block has run to completion.

So the queue will be retained by the system until the block completes the execution, but the self won't be retained in this case.

Thanks to @Wain for pointing out my mistake in the previous version of this answer.

like image 78
danypata Avatar answered Nov 16 '22 10:11

danypata