IOS - Swift NSString

0

Good,

I'm making an application where I'm going to measure the users BMI. I created the layout but in the code I'm having problems.

I have a button that, when sliding, changes the height or weight value.

var w:Float = 75

alturachg(_ sender:UISlider) {
h = sender.value
lblAltura.text = NSString(Format: " %2.f m", h) }

Before closing } , it forces me to have the String not to give an error.

    
asked by anonymous 13.12.2016 / 11:09

1 answer

1

The value property of UISlider returns a float .

Just do a cast for String . You can do something like this:

h = String(sender.value)
    
02.08.2017 / 22:14