How I get the tag value from the sender
-
07-07-2019 - |
Question
- (IBAction)onClick1:(id)sender {
// Make sure it's a UIButton
if (![sender isKindOfClass:[UIButton class]])
return;
NSString *title = [(UIButton *)sender currentTitle];
}
I understand how to get the title and other current values but I don't see how I can get the value of the tag property.
Solution
I've got a test project here where I just used:
NSInteger i = [sender tag];
OTHER TIPS
You can simply call:
NSInteger the_tag = ((UIView*)sender).tag;
Each UIButton is a subclass of UIView which contains the tag
property.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow