0

I figured out how to put in array of selected elements when i click on row and i see .checkmark. And if i click the second time i see checkmark .none, but how i can remove selected elements from my array on which i clicked the second time?

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let cell = tableView.cellForRow(at: indexPath)
    if indexPath.section == 0 {
        if (cell?.accessoryType == .checkmark) {
            cell?.accessoryType = .none
            print("deselect - \(titleOptions[indexPath.row])")

            // how to remove selectedIndex from array???
            selectedIndexArray....

            print("\(selectedIndexArray)")
        } else {
            cell?.accessoryType = .checkmark
            print("select - \(titleOptions[indexPath.row])")
            selectedIndexArray.append(titleOptions[indexPath.row])
            print("\(selectedIndexArray)")
        }
    }
}

0 Answers0