title: Swift tried to present modally an active controller [Current view controller] even though the presented controller is another one
body: <p>I have read some answers like dismissing the current ViewController but my situation is different because I am presenting another ViewController.</p>
  
  <p>This code presents the view controller with its navigation controller although I cannot access it's properties:</p>
  
  <pre><code>@IBAction func didTouchAddFriend(_ sender: UIButton) {
  DispatchQueue.main.async {
  
      let storyBoard = UIStoryboard(name: "CustomContact", bundle: nil)
          let customContactVC = storyBoard.instantiateViewController(withIdentifier: "CustomContact")
  
  }
  }
  </code></pre>
  
  <p>While this one doesn't work</p>
  
  <pre><code>@IBAction func didTouchAddFriend(_ sender: UIButton) {
      DispatchQueue.main.async {
  
          let navigation = UIStoryboard.init(name: "CustomContact", bundle: nil).instantiateInitialViewController() as! UINavigationController
          let pickerUserVC = navigation.viewControllers.first as! CustomContactsViewController
          self.present(pickerUserVC, animated: true, completion: nil)
  
      }
  }
  </code></pre>
  
  <p>I have another story board named CustomContact.storyboard which containts a CustomContactsViewController</p>
  
  <p>When I click the didTouchAddFriend, it just shows me this error:</p>
  
  <pre><code>'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller &lt;Main.MainViewController: 0x7ff29f06ac00&gt;.'
  </code></pre>
  
  <p>I cannot understand the error cos when I printed the value of pickerUserVC, it show the right view controller: </p>
  
  <pre><code>&lt;Main.CustomContactsViewController: 0x7fd1b7922400&gt;
  </code></pre>
  
  <p>MainViewController is the current view controller implementing the didTouchAddFriend function</p>