The sender
should be the control which initiated the action. However, you should not assume its type and should instead leave it defined as an id
. Instead, check for the object’s class in the actual method as follows:
- (IBAction)onClick1:(id)sender {
// Make sure it's a UIButton
if (![sender isKindOfClass:[UIButton class]])
return;
NSString *title = [(UIButton *)sender currentTitle];
}