title: How to swipe right to show new View Controller in Swift 3?
body: <p>I want to be able to swipe right in my <code>ViewController</code> which will show another view controller, <code>CommunitiesViewController</code>.</p>
  
  <p>I have looked on other threads and found some ways of doing this though I believe they are for Swift 2.</p>
  
  <p>This is the code I am using in my <code>ViewController</code>:</p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
  
      let swipeRight = UISwipeGestureRecognizer(target: self, action: Selector(("respondToSwipeGesture")))
      swipeRight.direction = UISwipeGestureRecognizerDirection.right
      self.view.addGestureRecognizer(swipeRight)
  }
  
    func respondToSwipeGesture(gesture: UIGestureRecognizer) {
  
      print ("Swiped right")
  
      if let swipeGesture = gesture as? UISwipeGestureRecognizer {
  
          switch swipeGesture.direction {
  
          case UISwipeGestureRecognizerDirection.right:
  
  
              //change view controllers
  
              let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
  
              let resultViewController = storyBoard.instantiateViewController(withIdentifier: "CommunitiesID") as! CommunitiesViewController
  
              self.present(resultViewController, animated:true, completion:nil)    
  
  
          default:
              break
          }
      }
  }
  </code></pre>
  
  <p>I have given <code>CommunitiesViewController</code> a storyboard ID of <code>CommunitiesID</code>.</p>
  
  <p>But this does not work and the app crashes when I swipe right with the following error:</p>
  
  <blockquote>
    <p>libc++abi.dylib: terminating with uncaught exception of type NSException</p>
  </blockquote>