NSObject+AssociatedObject.h
@interfaceNSObject(AssociatedObject)
@property(nonatomic,strong)idassociatedObject;
@end
NSObject+AssociatedObject.m
@implementationNSObject(AssociatedObject)
@dynamicassociatedObject;
-(void)setAssociatedObject:(id)object{
? ? ? objc_setAssociatedObject(self,@selector(associatedObject),object,OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
-(id)associatedObject{
? ? ? ?returnobjc_getAssociatedObject(self,@selector(associatedObject));
}