I have a UITableView
with a few rows e.g. row1 , row2 , row3. I also have 3 UIviewControllers e.g. A , B , C.
When I select row1 in the table view I want to display view controller A.
When I select row2 in the table view I want to display view controller B.
When I select row3 in the table view I want to display view controller C.
I want to do this with an if statement.
I have selected the UITableViewCell and ctrl + dragged it over to the view controllers to create a segue that can be called. However it wont let me create multiple segues between the UITableViewCell and the various viewControllers.
override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == 0 {
self.performSegueWithIdentifier("A", sender: self)
}
if indexPath.row == 1 {
self.performSegueWithIdentifier("B", sender: self)
}
if indexPath.row == 2 {
self.performSegueWithIdentifier("B", sender: self)
}
}
I am using swift 2.
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//handle your code here
}
what mistake you have done is:you have handled in didDeselectRowAtIndexPath
for multiple segues: refer the image