How to set a CGFloat to a UILabel's text property

Jab picture Jab · Dec 30, 2009 · Viewed 14.7k times · Source

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.

Answer

Ben Gottlieb picture Ben Gottlieb · Dec 30, 2009

You can try:

[NSString stringWithFormat: @"%.2f", myFloat];