Hi I'm trying to remove the cell when the checkbox is selected but the function keeps removing cell at index 0 instead of selected cell index
Set up Cell with tag
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! TableViewCell
let task = tasks[indexPath.row]
cell.delegate = self
cell.tag = indexPath.row
print("The tag is \(cell.tag)")
CustomTableViewCell
protocol TableViewCellDelegate {
func RadioTapped(_ tag: Int)
}
class TableViewCell: UITableViewCell {
var delegate: TableViewCellDelegate?
@IBOutlet var radioButton: BEMCheckBox!
@IBOutlet var taskText: UILabel!
@IBAction func radioTapped(_ sender: UIView){
delegate?.RadioTapped(sender.tag)
}
Function called when radiobutton is tapped
func RadioTapped(_ tag: Int) {
print("Radio Tapped at \(tag)")
}
RadioTapped always print "Radio tapped at 0"