Created
August 23, 2012 11:02
-
-
Save orip/3435552 to your computer and use it in GitHub Desktop.
WEAKSELF macro for Objective-C and ARC
This file contains hidden or 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
/* | |
Usage: | |
WEAKSELF_T weakSelf = self; | |
dispatch_async(queue, ^{ | |
[weakSelf coolStuff]; | |
}); | |
*/ | |
#if __has_feature(objc_arc_weak) | |
#define WEAKSELF_T __weak __typeof__(self) | |
#else | |
#define WEAKSELF_T __unsafe_unretained __typeof__(self) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment