title: Pop a navigation controller
body: <p>I have two views, V1 and V2.  I want to "present" V2 when the add button is pressed on V1, and "pop" V2 off when the stop button is pressed, so that the original V1 is the top of the stack.</p>
  
  <p>From what I have read, I need a separate view controller for V2.  From the limited information I could find, I need V1's view controller to conform to V2's protocol, V2delegate.  This is what I have, but it is not working:</p>
  
  <p><strong>ViewController1 with V1</strong></p>
  
  <pre><code>class HomeController: UICollectionViewController, UICollectionViewDelegateFlowLayout, FormViewControllerDelegate {
  
      let form = FormViewController()
  
      func addTapped() {
          form.delegate = self
          let nav = UINavigationController(rootViewController: form)
  
          navigationController?.present(nav, animated: true)
      }
  
      func popForm() {
          navigationController?.popViewController(animated: true)
          navigationController?.popToViewController(self, animated: true)
          print("popped")
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Ox4zpm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ox4zpm.png" alt="enter image description here"></a></p>
  
  <p><strong>ViewController2 with V2</strong></p>
  
  <pre><code>class FormViewController: UIViewController {
  
      var delegate: FormViewControllerDelegate?
  
      func stopTapped() {
          print("pop it")
          delegate?.popForm()
      }
  }
  
  protocol FormViewControllerDelegate {
      func popForm()
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/boDQam.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/boDQam.png" alt="enter image description here"></a></p>
  
  <p>What am I doing wrong here?</p>