// My Button code
UIButton *ticketButtonObj=[[ticketButton alloc]initWithFrame:CGRectMake(0.0f, 115.0f, 500.0f, 40.0f) ;
int col=10;
[ticketButtonObj addTarget:self action:@selector(ShowNumber:) forControlEvents:UIControlEventTouchUpInside];
[self.window addSubview:ticketButtonObj];
// ...
- (void) ShowNumber:(id)sender{
// here i want to get the Value of Col
}
在上面的代码中,当我按下按钮时,我想打印col变量的值在ShowNumber
方法中。我怎样才能做到这一点?如何在按下UIButton时打印此变量的值?