Setting the text of a UILabel to an int?
11,533
Solution 1
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];
Solution 2
NSNumber *number = [NSNumber numberWithInt:yourInt];
[yourLabel setText:[number stringValue]];
Solution 3
label.text = [NSString stringWithFormat:@"%i",intNumber];
Author by
Fitzy
Donate: Bitcoin: 18YFRUwQne2cPivXSGWL7AffoCK2qR71Bi Ethereum: 0xAD66D5F9BC59924152361ce4B58aA8fa63A9a9Ae
Updated on June 07, 2022Comments
-
Fitzy almost 2 years
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!