The question is pretty much self explanatory. I need to set the text property of a UILabel instance to an int. How do I go about doing this? Sorry if it's a nooby question.
Thanks!
Assuming you have:
UILabel *myLabel; //instance of your label
int myInt; //the integer you need to set as text into UILabel
you can do this, and it's pretty simple:
[myLabel setText:[NSString stringWithFormat:@"%d", myInt]];
or:
myLabel.text = [NSString stringWithFormat:@"%d", myInt];
NSNumber *number = [NSNumber numberWithInt:yourInt];
[yourLabel setText:[number stringValue]];
label.text = [NSString stringWithFormat:@"%i",intNumber];
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