UIAlertView利用runtime传值

1.首先声明alertView

 NSMutableDictionary *parame = [NSMutableDictionary dictionary];

    parame[@"aaa"] = @"111";

    parame[@"bbb"] = @"222";

    UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"aaa"message:@"bbb" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];

    [alertView show];

    

 

//存值

    objc_setAssociatedObject(alertView, "key", parame,OBJC_ASSOCIATION_RETAIN_NONATOMIC);

根据key存值

2.在alertView代理方法中取值。

-(void)alertView:(UIAlertView *)alertView clickeonAtIndex:(NSInteger)buttonIndex

{

    NSMutableDictionary *parame = objc_getAssociatedObject(alertView, "key");

    NSLog(@"fadsf---%@",parame);

 

}

你可能感兴趣的:(UIAlertView利用runtime传值)