title: how can I perform segue with another view only when email was sent?
body: <p>For some reason this code doesn't work it gives off the error:"Warning: Attempt to present * on * whose view is not in the window hierarchy". But i don't understand how to fix this. Here is my code.</p>
  
  <pre><code>    func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
      switch result {
      case .cancelled:
          print("Mail cancelled")
      case .saved:
          print("Mail saved")
      case .sent:
          print("Mail sent")
          self.performSegue(withIdentifier: "AllList", sender: self)
          AllListOfViolations.violationType.append("\(LocationAndTimeData.getSystemDate())")
      case .failed:
          print("Mail sent failure: \(error?.localizedDescription ?? "nil")")
      }
      controller.dismiss(animated: true, completion: nil)
  }
  </code></pre>