Skip to content

Instantly share code, notes, and snippets.

@ijoshsmith
Created September 28, 2012 17:59
Show Gist options
  • Save ijoshsmith/3801286 to your computer and use it in GitHub Desktop.
Save ijoshsmith/3801286 to your computer and use it in GitHub Desktop.
Safely access self from block using ARC
__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