你需要一个协议
protocol ReloadManager {
func callReload(cell:CartTableViewCell)
}
//
class CartViewController: UIViewController,UITableViewDataSource,UITableViewDelegate,ReloadManager {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier:"id") as! CartTableViewCell
cell.delegate = self
}
func callReload(cell:CartTableViewCell) {
cartsTableView.reloadData()
// use cell if you want to get indexpath to remove item from the table
}
}
//
class CartTableViewCell: UITableViewCell {
var delegate:ReloadManager?
func btnClicked(_ sender:UIButton){
delegate?.callReload(cell:self)
}
}