title: Swift: Multiple TableView checkmark - select all rows
body: <p>It is posible to add a <code>select all</code> option in TableView Multiple checkmarks...?</p>
  
  <p>I have a code ready, and I try to do this function. please help me !</p>
  
  <p><strong>CODE:</strong></p>
  
  <pre><code>struct Area {
          let name : String
          var isSelected : Bool
  
          init(name : String, isSelected : Bool = false) {
              self.name = name
              self.isSelected = isSelected
          }
      }
  
      var areas = [Area(name: "Select all"),Area(name: "a"),Area(name: "b"),Area(name: "c"),Area(name: "d"]
  
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int
      {
          return areas.count
      }
  
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell{
          let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
          let area = areas[indexPath.row]
          cell.textLabel?.text = area.name
          cell.accessoryType = area.isSelected ? .checkmark : .none
  
          return cell
      }
  
      func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
          areas[indexPath.row].isSelected.toggle()
          tableView.reloadRows(at: [indexPath], with: .none)
          let selectedAreas = areas.filter{$0.isSelected}.map{$0.name}
          print(selectedAreas)
  
      }
  </code></pre>
  
  <p>Thanks.</p>