title: Performing segue after sender view controller is dismissed
body: <p>Basically, I have a button in a slide-out menu (which is its own view controller that covers part of the <code>Origin</code> screen, let's call it <code>Menu</code>) that, when pressed, performs a modal segue to another controller, let's say <code>Destination</code>.</p>
  
  <p>Is there any way that upon pressing the button in <code>Menu</code> (to go to <code>Destination</code>), that I can dismiss <code>Menu</code> back to <code>Origin</code>, and THEN segue to <code>Destination</code>?</p>
  
  <p>It sounds silly but it's something that I think I've seen apps do before. In my case, the reason for wanting to do this is that once I press "Done" on <code>Destination</code>, it dismisses that controller back to <code>Menu</code>, when I want it to just dismiss back to <code>Origin</code>. I can't just perform a segue back to <code>Origin</code> from <code>Destination</code>.</p>
  
  <p>Code:</p>
  
  <p>This is how I open the <code>Menu</code> from <code>Origin</code>:</p>
  
  <pre><code>let interactor = Interactor()
  
  @IBAction func openMenu(_ sender: AnyObject) {
      performSegue(withIdentifier: "openMenu", sender: nil)
  }
  
  
  @IBAction func edgePanGesture(sender: UIScreenEdgePanGestureRecognizer) {
      let translation = sender.translation(in: view)
  
      let progress = MenuHelper.calculateProgress(translationInView: translation, viewBounds: view.bounds, direction: .Right)
  
      MenuHelper.mapGestureStateToInteractor(
          gestureState: sender.state,
          progress: progress,
          interactor: interactor){
              self.performSegue(withIdentifier: "openMenu", sender: nil)
      }
  }
  
  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
      if let destinationViewController = segue.destination as? MenuViewController {
          destinationViewController.transitioningDelegate = self
          destinationViewController.interactor = interactor
          destinationViewController.currentRoomID = self.currentRoomID
      }
  }
  </code></pre>
  
  <p>This is my <code>prepareForSegue</code> from <code>Menu</code> to <code>Destination</code> currently, nothing fancy:</p>
  
  <pre><code>override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
      super.prepare(for: segue, sender: sender)
  
      let inviteVC = segue.destination as! InviteVipViewController
      inviteVC.currentRoomID = self.currentRoomID
  }
  </code></pre>
  
  <p>And finally to dismiss <code>Destination</code> is just a simple</p>
  
  <pre><code>@IBAction func cancelButtonPressed(_ sender: Any) {
      self.dismiss(animated: true, completion: nil)
  }
  </code></pre>
  
  <p>I saw this question which is basically what I'm trying to do but there was no answer unfortunately: <a href="https://stackoverflow.com/questions/42459786/performing-segue-after-dismissing-modal-swift">Performing segue after dismissing modal swift</a></p>
  
  <p>Sorry if this sounds confusing, but if anyone knows what I'm talking about and can let me know how I can set up the segues/<code>prepareForSegue</code>s to make it work, any input would be appreciated!</p>