Get UIButton Text from sender

joec picture joec · Jul 3, 2010 · Viewed 13.2k times · Source

How can i obtain the text of a UIButton in my

-(IBAction)clicked:(id)sender

method?

Thanks

Answer

Douwe Maan picture Douwe Maan · Jul 3, 2010

What about this:

- (IBAction)clicked:(id)sender {
  UIButton *button = (UIButton *)sender; 
  NSString *buttonTitle = button.currentTitle;
}