I am trying to accomplish something that seems simple enough: I have a UITableView with dynamic UITableViewCells. When each cell is selected, I want to perform a segue to a different view controller in my Storyboard. However, I want to create the segues programatically because I want to determine which ViewController gets called at runtime. However, I can't seem to get it to work.
Here's how I set up my code for the cell selection:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if(indexPath.row==0){
var calculoViewController = CalculoViewController()
var calcSegue = UIStoryboardSegue(identifier:"Menu_Calc", source: self, destination: calculoViewController)
self.performSegueWithIdentifier("Menu_Calc", sender: self)
}
else
{
var deducVC = DeductionsViewController()
var deducSegue = UIStoryboardSegue(identifier: "Menu_Deduc", source: self, destination: deducVC)
self.performSegueWithIdentifier("Menu_Deduc", sender: self)
}
}
However, this fails with: NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'Menu_Calc''
Note that I don't have any drawn segues in my Storyboard, that is why I am creating them dynamically. Previously I tried drawing them by connecting the prototype cell with the ViewControllers, but then every cell called the same segue, despite the code.