Skip to content

Instantly share code, notes, and snippets.

@jyliang
Created June 3, 2014 00:39
Show Gist options
  • Save jyliang/77398e4c217fa7d58830 to your computer and use it in GitHub Desktop.
Save jyliang/77398e4c217fa7d58830 to your computer and use it in GitHub Desktop.
@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