I have a UILabel
called optionsDisplayerBrushSizeLabel
who's text property I want to set to a CGFloat
: brushSizeVal
. I understand that the text property needs to be a string but I don't know how to convert a CGFloat to an NSString
.
Asked
Active
Viewed 1.5k times
2 Answers
32
You can try:
[NSString stringWithFormat: @"%.2f", myFloat];

Groot
- 13,943
- 6
- 61
- 72

Ben Gottlieb
- 85,404
- 22
- 176
- 172
-
1I think there should [NSString stringWithFormat: @"%.2f", myFloat]; for floats. – Madhup Singh Yadav Dec 30 '09 at 05:25
-
you are entirely correct, I've edited my answer, sorry, a typo. – Ben Gottlieb Dec 30 '09 at 14:10