Excluir uma linha da exibição de tabela usando o botão personalizado - Swift 3
Como excluir uma linha da tableview usando o botão personalizado
//CustomCell.swift
protocol FavoriteCellDelegate {
func deleteButton(sender:CustomCell)
}
class FavoriteItemTableViewCell: UITableViewCell{
var delegate: FavoriteCellDelegate!
@IBAction func deleteButton(_ sender: UIButton) {
delegate.deleteButton(sender: self)
}
}
CustomClass:UITableViewDataSource,UITableViewDelegate,CustomCellDelegate{
@IBOutlet weak var tableView: UITableView!
// all necessary functions for table view....
// Function delegated to perform action.
func deleteButton(sender:FavoriteItemTableViewCell){
//How should I delete. How can I get index path here
}
}
P. o que devo escrever na função deleteButton? Não consigo obter o indexPath aqui, então o que devo fazer? Eu já tenho outro botão na célula e a delegação está funcionando bem.