Reputation: 25
I have used segue, which should pass the index of cell that was pressed in my TableView, but the problem is that function didSelectRowAt
runs after my segue. That sague was made by control dragging from a custom cell to another view.
Here is my code:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
selectedScheduleN = indexPath.row
self.performSegue(withIdentifier: "edit", sender: nil)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
switch(segue.identifier ?? "") {
case "edit" :
print ("normal function")
var dest : editScheduleViewController = segue.destination as! editScheduleViewController
dest.x = selectedScheduleN
case "add" : return
default : return
}
}
Thanks in advance!
Upvotes: 0
Views: 84
Reputation: 54805
Do not add the segue to the cell itself in Storyboard
. Delete your existing segue and add a manual segue from your table view controller by ctrl dragging from the yellow Navigation
icon on top of the view controller.
Upvotes: 1