My iPhone app has many buttons and I want all the buttons to call the same method, but with different parameters.
For example I want tapping one button to call the m
You can't pass parameters through an IBAction. What I usually do is give the buttons the unique tag in IB. THe tag is an integer value so I u then use a simple lookup table to convert the tag to some value.
In this case, three buttons but tags 1 to 3:
- (IBAction) buttonPressed: (UIButton*) sender
{
static const NSString* names = { @"Foo", @"Bar", @"Baz" };
id tag = [sender tag];
if (tag >= 1 && tag <= 3) {
NSLog(@"Button pressed is %@", names[tag]);
}
}