Created
June 25, 2013 20:21
-
-
Save derrh/5862005 to your computer and use it in GitHub Desktop.
Synthesize + objc_get/setAssociatedObject
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
#import <objc/runtime.h> | |
#define SYNTHESIZE(class, getter, setter) \ | |
static const void *getter##PropertyKey = &getter##PropertyKey;\ | |
- (type *)getter { \ | |
return objc_getAssociatedObject(self, getter##PropertyKey); \ | |
} \ | |
\ | |
- (void)setter:(class *object) { \ | |
objc_setAssociatedObject(self, getter##PropertyKey, object, OBJC_ASSOCIATION_RETAIN);\ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment