0
votes

I have a Split Controller with cells in the master view controller. When I click on a specific cell, I want the detail view controller to switch to a specific view controller that I have on my storyboard.

I tried connecting the two view controllers (master to new view controller), gave the new controller a storyboard ID "NewDetailSegue" and tried this code:

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    if (indexPath.row == 0) {            
        self.performSegueWithIdentifier("NewDetailSegue", sender: self)
}

but it does not work at all and crashes. How do I have the detail view controller segue to a new view controller?

Here is the error:

2015-04-10 22:06:44.180 velcro[3616:174510] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<velcro.MainReportController: 0x7feeb95881b0>) has no segue with identifier 'NewDetailSegue'
1
It should just work. What kind of segue did you use?matt
I tried 'show' and 'show detail'.user2836857
Show Detail is right. - Okay, let me ask you this: are we now conflicting with another segue that automatically happens when you click on other rows? I mean, if you already had a segue from the prototype cell to a normal detail view, that segue does not magically go away. And that segue is triggered when you click on a cell. So now we are trying to do two segues at once, which sounds like a recipe for disaster.matt
Oh, sorry, one more thing. Any time you get a crash, you get really useful info in the console explaining why. Does that info tell us what the problem is? Copy it out and paste it into your question, please.matt
Here is the error: 2015-04-10 22:06:44.180 velcro[3616:174510] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<velcro.MainReportController: 0x7feeb95881b0>) has no segue with identifier 'NewDetailSegue'' I do not believe there is a conflict of segues.user2836857

1 Answers

1
votes

gave the new controller a storyboard ID "NewDetailSegue"

But it is the segue that needs the identifier "NewDetailSegue" - not the view controller. I'm betting that when you get the identifier attached to the segue in the storyboard, your crash will go away.