title: Swift: Using toolbar button to delete multiple cells in a TableView
body: <p>I am currently working on a todo app using core data. The user is able to mark todos as completed. Now, I want to add a button to the toolbar which supposes to delete every marked todo on a single tab. I already configured swipe actions to delete and mark on cell at a time. I cant provide any code for this situation, simply because I got no specific idea how to implement this. The code provided down below shows how I configured the delete swipe. Maybe this can help to come up with a solution.</p>
  
  <pre><code>override func tableView(_ tableView: UITableView,
                 trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -&gt; UISwipeActionsConfiguration?
  {
  
      let deleteAction = UIContextualAction(style: .destructive, title:  "Delete", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -&gt; Void) in
  
          //Haptic Feedback
          AudioServicesPlaySystemSound(1519)
  
          //Animation
          let range = NSMakeRange(0, self.tableView.numberOfSections)
          let sections = NSIndexSet(indexesIn: range)
          self.tableView.reloadSections(sections as IndexSet, with: .fade)
  
          //Call delete function from CoreDataManager.swift
          let todo = CoreDataManager.shared.getTodoItem(index: indexPath.row)
          CoreDataManager.shared.deleteItems(item2: todo)
          tableView.reloadData()
          success(true)
      })
      deleteAction.image = UIImage(named: "trash1")
      deleteAction.backgroundColor = .red
  
      return UISwipeActionsConfiguration(actions: [deleteAction])
  }
  </code></pre>