Created
June 3, 2014 00:39
-
-
Save jyliang/77398e4c217fa7d58830 to your computer and use it in GitHub Desktop.
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
@interface NSObject (category) | |
@property (nonatomic, copy, setter = setObjectInfo:) id objectInfo; | |
@end | |
#import <objc/runtime.h> | |
static char kObjectInfoDictionaryKey; | |
@implementation NSObject (category) | |
- (void)setObjectInfo:(id)objectInfo { | |
objc_setAssociatedObject(self, &kObjectInfoDictionaryKey, objectInfo, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | |
} | |
- (id)objectInfo { | |
return objc_getAssociatedObject(self, &kObjectInfoDictionaryKey); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment