I am fairly new to iOS development. I can’t figure out what I am doing wrong for the life of me. I am getting the
“Thread 1: EXC_BAD_INSTRUCTION (code=EXC_l386_NVOP, subcode=0x0)”
error with the menCalories variable. In the debugger I am getting the error:
“fatal error: unexpectedly found nil while unwrapping an Optional value"
Here is my code. Any help would be very much appreciated.
@IBAction func calculate(sender: AnyObject) {
var ageInt:Int? = age.text!.toInt()
var weightInt:Int? = weightLabel.text!.toInt()
var heightInt:Int? = height.text!.toInt()
if gender.selectedSegmentIndex == 0 {
let menCalories:Double = 66.47 + (13.75 * Double(weightInt!)) + (5.0 * Double(heightInt!)) - (6.75 * Double(ageInt!))
calories.text = "\(menCalories)"
}
if gender.selectedSegmentIndex == 1 {
}
}