#import
//挂载对象所需要的参数(UIAlertView挂载对象)
static const char kRepresentedObject;//挂载
- (void)AssociatedObjectTEST
{UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"test Runtime" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"去看看", nil];alert.tag = 9999;objc_setAssociatedObject(alert, &kRepresentedObject,@"我是被挂载的",OBJC_ASSOCIATION_RETAIN_NONATOMIC);[alert show];}- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{if (buttonIndex == 1){NSString *str = objc_getAssociatedObject(alertView,&kRepresentedObject);NSLog(@"%@",str);}
}