tags:

views:

959

answers:

1

//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

}

in the above code when i pressed the button.. i want print the value of col variable in ShowNumber method .. how it is ?

pls Help me ...

thanks and regards... by raju

A: 

Col is a local variable and is therfore destroyed after the method returns.

you need to create a instance variable for you to be able to access the value.

Bluephlame