Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simply create associated property with one line of code using a reusable preproc macro
#import <objc/runtime.h>
#define ASSOCIATIVE_PROPERTY(GET_NAME, SET_NAME, TYPE, ASSOCIATION_POLICY) \
static char GET_NAME##Key; \
- (TYPE) GET_NAME \
{ \
return objc_getAssociatedObject(self, & GET_NAME##Key); \
} \
\
- (void) SET_NAME:(TYPE)value\
{\
objc_setAssociatedObject(self, & GET_NAME##Key, value, ASSOCIATION_POLICY);\
}
// Usage
// In category @interface
@property (nonatomic, retain) NSString* oldString;
// In category @implementation
ASSOCIATIVE_PROPERTY(oldString, setOldString, NSString*, OBJC_ASSOCIATION_RETAIN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.