Setting UILabel text to int?

The question is largely self explanatory. I need to set the text property of a UILabel instance to int. How can I do it? Sorry if this is a nooby question.

Thanks!

+6
source share
4 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 is pretty simple:

 [myLabel setText:[NSString stringWithFormat:@"%d", myInt]]; 

or

 myLabel.text = [NSString stringWithFormat:@"%d", myInt]; 
+12
source
 NSNumber *number = [NSNumber numberWithInt:yourInt]; [yourLabel setText:[number stringValue]]; 
+3
source
 label.text = [NSString stringWithFormat:@"%i",intNumber]; 
+2
source

Try the following:

  [label setText:[NSString stringWithFormat:@"%d", intValue]]; 
0
source

Source: https://habr.com/ru/post/910689/


All Articles