Take the 2-minute tour ×

I understand that Objective C will retain localVariable,

id localVariable = instanceVariable;

dispatch_async(queue, ^{
    // localVariable is used by value, localVariable is retained (not self)

but this retain is happened just when block is triggered ? if so, while the localVariable is an UI object such as UIViewController which maybe controlled by autorelease pool, if I just create an UIViewController managed by autorelease pool and not retain it or use it, while one event loop finished, it will be dealloced, then inside the block, I can't use this UIViewController anymore ? and I have to retain it manually outside block ?

share|improve this question

1 Answer 1

No, localVariable will be retained by the block when the block is created.

share|improve this answer

Your Answer


