// 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時打印此變量的值?