http://www.jianshu.com/p/35df1ba1f107
OBJC_EXPORT void objc_setAssociatedObject(id object, const void *key, id value, objc_AssociationPolicy policy)
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_1);OBJC_EXPORT id objc_getAssociatedObject(id object, const void *key)
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_1);简单的说:objc_setAssociatedObject是为对象动态添加属性和值,objc_getAssociatedObject是动态获得对象的属性值。
objc_setAssociatedObject(id object, const void *key, id value, objc_AssociationPolicy policy)相当于动态添加属性
object.key = valueobjc_getAssociatedObject(id object, const void *key)相当于
值 = object.key