-(void)myButtonclick {
NSString *data=[[NSString alloc]initWithString:@"YES U PRESSED BUTTON"];
UIButton *refreshbutton=[UIButton buttonWithType:UIButtonTypeCustom];
[refreshbutton setFrame:CGRectMake(15.0f, 330.0f, 150.0f, 32.0f)];
[refreshbutton setCenter:CGPointMake(80.0f,340)];
[refreshbutton setBackgroundImage: normalImage forState: UIControlStateNormal];
[refreshbutton setBackgroundImage: downImage forState: UIControlStateHighlighted];
[refreshbutton setBackgroundImage: selectedImage forState: UIControlStateSelected];
[refreshbutton setTitle:@"Refresh" forState:UIControlStateNormal];
[refreshbutton addTarget:self action:@selector(showMessage:) forControlEvents:UIControlEventTouchUpInside];
}
-(id)showMessage:(id)sender{
// Here I want to get the value of "data" which is defined the method
// "myButtonclick" in the first line. how it is possible..?
}
In the above code in the method "myButtonclick" I set one NSString variable name is "data" I want to get (print there) its value (YES U PRESSED BUTTON) in the method "showMessage" when I press that button.
I know this is done using @selector variable.. but I don't know how it is done