Sending data back to previous View Controller when tableViewCell pressed

时间:2019-03-19 15:18:02

标签: swift

I currently have a tableViewController that is being populated with data sent from the previous viewController with prepareForSegue. I'm now trying to send the data back based on the cell that the user selects so that I can save the item the user selected.

I figure that the best way to go about this is to use an unwindSegue, but I am unsure how best to implement it. Can someone point me in the right direction?

1 个答案:

答案 0 :(得分:0)

在这里您需要在prepareForSegue集内的代表

let des = segue.destination as! NextVC
des.delegate = self

然后在nextVC内访问上一个VC并保存任何数据,如果当前未通过索引,则可以使用delegate?.tableView.indexPathForSelectedRow