Skip to content

Instantly share code, notes, and snippets.

@dmdeller
Last active August 29, 2015 13:57
Show Gist options
  • Save dmdeller/9534976 to your computer and use it in GitHub Desktop.
Save dmdeller/9534976 to your computer and use it in GitHub Desktop.
Trying to avoid having ugly weakBlah variables all over the place to avoid retain cycles (or at least having to look at them)
__weak __typeof__(foo) weakFoo = foo;
foo.block = ^
{
[weakFoo doSomething];
};
#define HNHWeakCapture(obj) __weak __typeof__(obj) _HNHWeak_##obj = obj
#define HNHWeakRef(obj) _HNHWeak_##obj
HNHWeakCapture(foo);
foo.block = ^
{
[HNHWeakRef(foo) doSomething];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment