Dear all I have this problem:
I have a table view with some row, in every row there is a button, a when it is submitted, I have to make some update (php) via json.
My problem is that I'm not able to get the indexpath row to clean the table after the php update.
Does anyone encountered the same problem and can help me?
Thanks in advance,
Angelo.
Here's an alternative to storing the row number in a tag:
@IBAction func submit(_ sender: UIButton) {
var superview = sender.superview
while let view = superview, !(view is UITableViewCell) {
superview = view.superview
}
guard let cell = superview as? UITableViewCell else {
print("button is not contained in a table view cell")
return
}
guard let indexPath = tableView.indexPath(for: cell) else {
print("failed to get index path for cell containing button")
return
}
// We've got the index path for the cell that contains the button, now do something with it.
print("button is in row \(indexPath.row)")
}