How to do it...

  1. Let's start with deleting lists. Open the TasksListManager.swift file, and add the following function:
     func deleteList(list: TaskList){ 
 
          self.managedObjectContext.delete(list) 
          do{ 
              try self.managedObjectContext.save() 
          } 
          catch{ 
              print(error) 
          } 
      } 
 
  1. Add the following extension to implement the UITableViewDelegate protocol and override the editActionsForRow function:
 extension TasksListsViewController: UITableViewDelegate{ func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { let deleteAction = UITableViewRowAction(style: .destructive, title: "Delete", handler: { (deleteAction, indexPath) in let tasksListsManager = TasksListManager() let listToBeDeleted = self.tasksLists[indexPath.row] ...

Get iOS Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.