1. Dynamic to add method to NSObject
@interface NSObject (CategoryWithProperty)
@property (nonatomic, strong) NSObject *property;
@end
@implementation NSObject (CategoryWithProperty)
– (NSObject *)property {
return objc_getAssociatedObject(self, _cmd);
}
– (void)setProperty:(NSObject *)value {
objc_setAssociatedObject(self, @selector(property), value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
2. Dynamic extension attributes
}
}
@end