Last active
December 19, 2015 13:40
-
-
Save volodg/5531956 to your computer and use it in GitHub Desktop.
objc_getAssociatedObject example
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
#include <objc/runtime.h> | |
static char dynamicPropertyKey; | |
@interface TestClass (ParseObject) | |
@property (nonatomic) NSObject *dynamicProperty; | |
@end | |
@implementation TestClass (ParseObject) | |
- (NSObject *)dynamicProperty | |
{ | |
return objc_getAssociatedObject(self, &dynamicPropertyKey); | |
} | |
- (void)setDynamicProperty:(NSObject *)dynamicProperty | |
{ | |
objc_setAssociatedObject(self, | |
&dynamicPropertyKey, | |
dynamicProperty, | |
OBJC_ASSOCIATION_RETAIN_NONATOMIC); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment