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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.