When referencing a weak ivar inside of a block in Objective-C when ARC is enabled, does the runtime implicitly retain the object to which the ivar belongs? For example:
- (void) foo {
void (^block)() = ^{
[_weakIvar doSomethingAwesomeButNotTooAwesome]; // Is self retained here?
}
block();
}
While we’re at it, how about a weak property in the same scenario?
- (void) foo {
void (^block)() = ^{
[self.weakProperty doSomethingAwesomeReallyAwesomeDudeYeah];
}
block();
}
_weakIvarreally meansself->_weakIvarunder the hood which means that what is (automatically) retained isself. Same thing applies when doingself.weakProperty.In your particular example, the block is not copied (and used right away) so nothing is retained at all but if you do (for example):