TableView CheckMark e desmarque com rolagem para cima ainda verificado o valor da célula no Ios Swift 4

O valor da célula do TableView CheckMark removido após a rolagem para cima Ele corrigirá o TableView em Você enfrentou um problema muitas vezes para marcar após a rolagem para cima e depois para baixo para exibir a célula da sua marca de seleção será removida porque a célula é dequeueReusableCell Portanto, esse problema foi corrigido Seu código e resolveu seu problema.

Mais alguma ajuda para enviar massagem. Muito obrigado. :)

class ViewController: UIViewController , UITableViewDataSource , UITableViewDelegate{

var temp = [Int]()
var numarr = [Int]()

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return numarr.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    var cell = tableView.dequeueReusableCell(withIdentifier: "id")
    cell = UITableViewCell.init(style: .default, reuseIdentifier: "id")
    cell?.textLabel?.text = String(numarr[indexPath.row])
    if temp.contains(numarr[indexPath.row] as Int)
    {
        cell?.accessoryType = .checkmark
    }
    else
    {
        cell?.accessoryType = .none
    }
    return cell!
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    let cell = tableView.cellForRow(at: indexPath)
    if temp.contains(numarr[indexPath.row] as Int)
    {
        cell?.accessoryType = .none
        temp.remove(at: temp.index(of: numarr[indexPath.row])!)
    }
    else
    {
        cell?.accessoryType = .checkmark
        temp.append(self.numarr[indexPath.row] as Int)
    }
}

override func viewDidLoad() {
    super.viewDidLoad()
    for i in 1...100
    {
        numarr.append(i)
    }
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

questionAnswers(2)

yourAnswerToTheQuestion