The tag value is an Integer:
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:addressField forState:UIControlStateNormal];
[button addTarget:self action:@selector(pickTheQuiz:) forControlEvents:UIControlEventTouchUpInside];
button.tag=1;//or what other integer value, i need to put a string value
In the receiver method:
-(void)pickTheQuiz:(id)sender{
NSLog(@"The part number is:%i",((UIControl*)sender).tag);//i need to receive a string value instead of numeric value
}
You can convert the integer value of a tag to a NSString with:
[NSString stringWithFormat:@"%i", ((UIControl*)sender).tag];
Or, if you really need a string as identifier for an UI object, just subclass it and add a property like:
@property (nonatomic, strong) NSString *stringID;
And then use it instead of use the tag property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With