1、在.h文件里:
#import@interface NSObject (Property)@property (nonatomic, strong) id propretyName;@end
2、在.m文件里
#import "NSObject+Property.h"#import@implementation NSObject (Property)- (id)propretyName{ return objc_getAssociatedObject(self, @selector(propretyName));}- (void)setPropretyName:(id)propretyName{ objc_setAssociatedObject(self, @selector(propretyName), propretyName, OBJC_ASSOCIATION_RETAIN_NONATOMIC);}@end