-1

I keep getting a Unexpectedly found nil while unwrapping an Optional value, when it comes to the second &&

if Double(dependents.text!) ?? 1 >= 1 && Double(dependents.text!) ?? 1 <= 10 && Double(textField.text!)! >= 0.00  && Double(textField.text!)! <= 165.00 && marriageStatus.selectedSegmentIndex == 0{
              fedTax.text = String(0.00)
          }

That is my code, the bold "&&" is where I get the error.
If someone can help me, that would be great!
Thanks in advance.

sourab maity
  • 1,025
  • 2
  • 8
  • 16

1 Answers1

0

You get this error because you are force unwrapping dependents.text!- Check you have connected dependents outlet from storyboard. Otherwise, you could also safely unwrap it with

guard let dependentText = dependents.text! else {return}
Luca Sfragara
  • 624
  • 4
  • 16