Skip to content

Instantly share code, notes, and snippets.

@orip
Created August 23, 2012 11:02
Show Gist options
  • Save orip/3435552 to your computer and use it in GitHub Desktop.
Save orip/3435552 to your computer and use it in GitHub Desktop.
WEAKSELF macro for Objective-C and ARC
/*
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