Я хочу удалить определенную строку, когда я нажимаю кнопку в этой ячейке.но здесь строки удаляются на основе индекса.если я нажимаю кнопку в пятой строке, но 0-я строка индекса удаляется.
, пожалуйста, помогите мне.
вот мой код:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! EmployeeTableViewCell
//cell.empImage.image = UIImage(named: countryArray[indexPath.row])
cell.empName.text = namesArray[indexPath.row]
cell.cellExpendButton.tag = indexPath.row
cell.cellExpendButton.addTarget(self, action: #selector(expandcollapseButtonClicked), for: .touchUpInside)
cell.removeRowButton.addTarget(self, action: #selector(removerowButtonClicked), for: .touchUpInside)
return cell
}
@objc func removerowButtonClicked(sender : UIButton!) {
namesArray.remove(at: sender.tag)
self.tableView.reloadData()
}
Я хочу удалить ячейкув какую кнопку я нажал.