Puneet Puneet - 1 year ago 62
Swift Question

How do you round a UISlider to an int in swift

I was wondering how to round a UISilder value to a int value. Right now it is displaying floats. I am using swift 3 at the moment.

@IBOutlet var slidermove: UISlider!

@IBAction func SliderVal(_ sender: AnyObject) {

let x = round(slidermove)

round() does not work it will give an error, thanks for anyone that helps

Answer Source

Try Int(slidermove.value) instead this will parse it to an Int.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download