title: Nested DispatchQueue.main.async
body: <p>I'm showing alert in a function which I call from VC. I don't want main VC to be blocked. I'm calling this alert function in async. The function in turn has another async. Is this good practice or I'm doing it wrong? </p>
  
  <p>Can anyone suggest good practice for following code?</p>
  
  <pre><code>class MyVC: UIViewController {
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          // Don't block main thread
          DispatchQueue.main.async {
              self.showAlert(title: "Title", message: "Message")
          }
  
          // Do other stuff ...
  
      }
  }
  
  func showAlert(title: String = "", message: String) {
  
      alert = UIAlertController(title: title,message: message, preferredStyle: .alert)
      let cancelAction = UIAlertAction(title: "Ok", style: .cancel, handler: nil)
      alert.addAction(cancelAction)
  
      DispatchQueue.main.async {
          UIApplication.shared.keyWindow?.rootViewController!.present(alert, animated: true, completion: nil)
      }
  }
  </code></pre>