Created
September 28, 2012 17:59
-
-
Save ijoshsmith/3801286 to your computer and use it in GitHub Desktop.
Safely access self from block using ARC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__weak id weakSelf = self; | |
void (^aBlock)(void) = ^{ | |
<MyClass> *strongSelf = weakSelf; | |
if (strongSelf) | |
{ | |
// strongSelf->someIvar = 42; | |
// [strongSelf someMethod]; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment