关联传值

来源:互联网 发布:mac dobonnet口红试色 编辑:程序博客网 时间:2024/05/16 11:27
#import<objc/runtime.h>


//objc_setAssociatedObject需要四个参数:源对象,关键字,关联的对象和一个关联策略。
objc_setAssociatedObject(button,buttonKey, _imgView,OBJC_ASSOCIATION_RETAIN_NONATOMIC);


- (void)buttonPress:(UIButton*)sender//headButton点击
{
 UIImageView*imageView =  objc_getAssociatedObject(sender,buttonKey);
}

guan

0 0
原创粉丝点击