1

I am currently trying to segue to a different view controller when a button is pressed. The button's action method is called correctly, but when it calls the perform segue with identifier it crashes the app and says "terminating with uncaught exception of type NSException". I have the segue identifier as "switchToMap". I segue to the same page from a different place in the app as well, but that seems to work just fine. Does anyone have any ideas?

func mapButtonPressed (sender: UIButton) {
performSegueWithIdentifier("switchToMap", sender: sender)
}

The other place the map page is segued to looks like this. It is part of a switch statement.

  case 2:
  performSegueWithIdentifier("map", sender: indexPath.item)
arotc7
  • 11
  • 1
  • 1
    Normally, `terminating with uncaught exception of type NSException` is just the first few lines of the error, there should be a lot more information in the console when this happens. – dcestari Jun 16 '15 at 14:33
  • It says 'Receiver has no segue with identifier 'switchToMap'', except it does. Thats the only other helpful information in the console. – arotc7 Jun 16 '15 at 14:43
  • 2
    If it says that, it really doesn't have it. Check for typos in either the code or the storyboard, it's usually as simple as that. – dcestari Jun 16 '15 at 14:46
  • I found out what was wrong. if you used `self.navigationController.pushViewController()` it creates a new instance of that view controller that doesn't possess the segues that the storyboard instance has and so it doesn't have a segue with that particular identifier. Super annoying, so I just had to switch all my pushes to perform segues so that it would use the storyboard instance. – arotc7 Jun 16 '15 at 15:05
  • 1
    @arotc7 `pushViewController()` does not create any new instances... that would be a job for `init[WithSomething]` – Alladinian Jun 16 '15 at 15:26

0 Answers0