- 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) } }
- 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] ...