Trying to calculate BMI ( body mass index ) as an app in Swift. Making the calculate function I cannot find the solution
@IBOutlet weak var height: UITextField!
@IBOutlet weak var weight: UITextField!
@IBAction func calculate(_ sender: UIButton) {
}
@IBAction func reset(_ sender: UIButton) {
}
func calculateIMC(){
var textHeight = height.text
var textWeight = weight.text
var intHeight:Int? = Int(textHeight!) ?? 0
var intWeight:Int? = Int(textWeight!) ?? 0
let calculateHeight: Int? = (intHeight * intHeight)
}
Error message on the last line of code:
Binary operator '*' cannot be applied to two 'Int?' operands