App Crashes on performSegue(withIdentifier: id, sender: self)

I am trying to segue from a table view controller (prototype cells) to a view controller. At this time I am not trying to pass any data.

It crashes on:

//This is in the table view controller class

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)

{

self.performSegue(withIdentifier: "showReceiptDetails", sender: self)// Where showReceiptDetails is the id of the segue in the attributes inspector.

}


In the storyboard I set the segue id to "showReceiptDetails". The segue is of Kind "Push". I have attempted to control drag from the tableviewcontroller and from a prototype cell with in the table view. I get the same results.


Is there a step I am missing?

Accepted Reply

I actually just found the issue when I was searching for the crash log for you. I was inheriting from UITableViewController when I needed to be inheriting from UIViewController. I made this mistake along the way when I was attempting to get it to segue to any controller. Thank you for the help!

Replies

What is the exact crash log you get ?


Did you prepareForSegue ?


Something like (this is Swift 2, so you may have to adapt a little bit):


override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

if (segue.identifier == "showReceiptDetails") {

if let destinationVC = segue.destinationViewController as? DestinationViewController {

// Prepare attributes you have to prepare

}

}

}

I actually just found the issue when I was searching for the crash log for you. I was inheriting from UITableViewController when I needed to be inheriting from UIViewController. I made this mistake along the way when I was attempting to get it to segue to any controller. Thank you for the help!

Thanks for the follow up.