I've image in cell, I've added gesture recogniser for this image. After deleting a cell from table the indexPath of the cells below the deleted cell is incorrect which cause app to crash.
How do I get indexPath from gesture recogniser when image inside cell is tapped?
I've searched a lot but can't find a working solution. Below is the code which I've right now. This code returns incorrect row.
P.S. Please don't suggest adding button on top of Image as I'm already aware of this.
@objc func imageTapped(_ gesture:UITapGestureRecognizer){
guard let indexPath = myTableView.indexPathForRow(at: gesture.location(in: gesture.view)) else {
print("Error: indexPath)")
return
}
print("indexPath.row: \(indexPath.row)")
}