18

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.

Jab
  • 26,853
  • 21
  • 75
  • 114

2 Answers2

32

You can try:

[NSString stringWithFormat: @"%.2f", myFloat];
Groot
  • 13,943
  • 6
  • 61
  • 72
Ben Gottlieb
  • 85,404
  • 22
  • 176
  • 172
0

Tray this in swift

var a = String (stringInterpolationSegment:myFloat)
Binoy jose
  • 461
  • 4
  • 9