Last active
August 29, 2015 14:00
-
-
Save kenn/11273433 to your computer and use it in GitHub Desktop.
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
#define CLASS_PROPERTY_INTERFACE(TYPE, METHOD, CMETHOD) \ | |
+ (TYPE) METHOD; \ | |
+ (void) set##CMETHOD:(TYPE)val; \ | |
#define CLASS_PROPERTY_IMPLEMENTATION(TYPE, METHOD, CMETHOD) \ | |
static TYPE _##METHOD; \ | |
+ (TYPE) METHOD \ | |
{ @synchronized(self) { return _##METHOD; } } \ | |
+ (void) set##CMETHOD:(TYPE)val \ | |
{ @synchronized(self) { _##METHOD = val; } } \ |
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
// Setter | |
User.me = currentUser; | |
// Getter | |
User.me |
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
@interface User : NSObject | |
CLASS_PROPERTY_INTERFACE(User *, me, Me) | |
@end |
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
@implementation User | |
CLASS_PROPERTY_IMPLEMENTATION(User *, me, Me) | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment