Hello I have string "(with float
value)"
let floatstring : String = "23.24"
print(floatstring)
I want to convert float String
to Int
.
Thank you !
Option 1
let intNum = Int(Float(floatstring)!)
Option 2
if floatstring.rangeOfString(".") != nil {
let i = Int(floatstring.componentsSeparatedByString(".").first!)
print(i)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With