title: Why are my if functions not preventing the segue to the next view controller?
body: <p>I have a series of if functions that check if two text fields are empty (or just one of them) and if so, present an error message in a label. If both of the text fields are not empty, then it should execute a calculation and then segue to the following view controller and present the value from the equation in a label. However, even with if functions in place that check to see if the text fields are not nil, the segue still gets executed, even if they are nil, as do the error labels. Why are the if functions not preventing this?</p>
  <pre><code>@IBAction func CalcFlowRateEnd(_ sender: UIButton) {
    
      let volume = Double(VolTextField.text!)
      let time = Double(SecTextField.text!)
      let units = volumeUnitsPicker4.selectedRow(inComponent: 0)
      var selectedUnit = data[units]
  
          
          //milliliters error labels
      if selectedUnit == &quot;milliliters&quot; &amp;&amp; volume == nil &amp;&amp; time == nil {
              volErrorLabel.text = &quot;Enter Volume&quot;
              secErrorLabel.text = &quot;Enter Seconds&quot;}
          
      if selectedUnit == &quot;milliliters&quot; &amp;&amp; volume != nil &amp;&amp; time == nil {
              secErrorLabel.text = &quot;Enter Seconds&quot;}
          
      if selectedUnit == &quot;milliliters&quot; &amp;&amp; volume == nil &amp;&amp; time != nil {
              volErrorLabel.text = &quot;Enter Volume&quot;}
          
          
          //milliliters calc
      if selectedUnit == &quot;milliliters&quot; &amp;&amp; volume != nil &amp;&amp; time != nil{
      
      let volumeConvert = Double(volume!/1000)
      let timeConvert = Double(time! / 60)
      let flowRateMetric = Double(volumeConvert / timeConvert)
      let volumeImperial = Double(volume!/4546)
      let flowRateImperial = Double(volumeImperial / timeConvert)
      let roundedMetric = round(flowRateMetric * 100) / 100.0
      let roundedImperial = round(flowRateImperial * 100) / 100.0
              
      calcFlowRate.text = &quot;\(roundedMetric) liters per min or \(roundedImperial) gal per min&quot;
          
      func prepare(for segue: UIStoryboardSegue, sender: Any?) {
                   
      let flowRate = calcFlowRate.text ?? &quot;&quot;
      let destinationVC = segue.destination as! FlowRateCalcEndViewController
      destinationVC.flowRate = flowRate
              
      }
  </code></pre>