Last active
August 29, 2015 13:57
-
-
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)
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 __typeof__(foo) weakFoo = foo; | |
foo.block = ^ | |
{ | |
[weakFoo doSomething]; | |
}; |
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
#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