Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the text of a UILabel to an int?

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!

like image 596
Fitzy Avatar asked Mar 14 '12 09:03

Fitzy


3 Answers

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];
like image 89
Giorgio Marziani de Paolis Avatar answered Nov 10 '22 01:11

Giorgio Marziani de Paolis


NSNumber *number = [NSNumber numberWithInt:yourInt];
[yourLabel setText:[number stringValue]];
like image 39
janusfidel Avatar answered Nov 10 '22 02:11

janusfidel


label.text = [NSString stringWithFormat:@"%i",intNumber];
like image 23
Krrish Avatar answered Nov 10 '22 01:11

Krrish