title: How to select and deselect a row by tapping on it
body: <p>I have a UITableView with an UITableViewCell, and I want to select them by clicking on it and deselect them by another clicking on them.
  First, I have tried it with</p>
  
  <pre><code>func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
          // code
  }
  </code></pre>
  
  <p>But I have noticed that this function don't get performed when you click a second time on a cell; it gets performed when you click on another cell.
  But I want that you can click on several cells which are checked when you click on them.</p>
  
  <p>So I have made this code (simplified):</p>
  
  <pre><code>func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
          print("Selected")
          let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! LektionTableViewCell
          if cell.accessoryType == .none {
              print("Type = none")
              cell.accessoryType = .checkmark
              Lektion.insert(Dateien[indexPath.row], at: Lektion.count)
          } else if cell.accessoryType == .checkmark {
              print("Type = check")
              cell.accessoryType = .none
              Lektion.remove(at: indexPath.row)
          }
      }
  </code></pre>
  
  <p>But it doesn't work correctly:</p>
  
  <ol>
  <li>When I click on a cell, the text automatically turn to "Label" (The text it has in the view builder)</li>
  <li>When I click on a cell with a check, the check doesn't vanish and Xcode says "Type = none"; that is wrong.</li>
  </ol>
  
  <p>Can anybody help me?</p>