I advise you to read the Apple docs at developer.apple.com
"I have 67+89.06 Dollars."
// In order to get a Float value both operands need to be of type Float.
let valueCalculate = "I have \(Float(67) + Float((89.06))) Dollars"
print(valueCalculate)
// Convert String to Int
var stringNumber = "123456"
var convertToInt = Int(stringNumber)
// Convert Float value to Int
var stringNumber = "123456"
var convertToInt = Int(stringNumber)
//convert value of type Float written as a String to Float
var stringWithFloatValue = "123.250"
var stringtoFloatValue = Float(stringWithFloatValue)
//convert Float value to Int
if stringtoFloatValue != nil {
let floatToInt = Int(stringtoFloatValue!)
}
2
solved How to convert String and perform calculation in Swift? [closed]