title: Swift unexpectedly found nil while unwrapping an Optional value on let variable
body: <p>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</p>
  
  <blockquote>
    <p>“Thread 1: EXC_BAD_INSTRUCTION (code=EXC_l386_NVOP, subcode=0x0)”</p>
  </blockquote>
  
  <p>error with the menCalories variable. In the debugger I am getting the error:</p>
  
  <blockquote>
    <p>“fatal error: unexpectedly found nil while unwrapping an Optional value"</p>
  </blockquote>
  
  <p>Here is my code. Any help would be very much appreciated.</p>
  
  <pre><code>@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 {
  
      }
  
  }
  </code></pre>