Updating and deleting records from Core Data
While dealing with objects in databases, you will need to know how to update or delete objects. In Core Data, these kinds of operations are made easy and, with just simple APIs, you can perform these operations. In this section, we will see how a user can edit the name of task list or delete it.
How to do it...
Let's start with deleting lists. Open the
TasksListManager.swiftfile, 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
UITableViewDelegateprotocol and override theeditActionsForRowfunction:extension TasksListsViewController: UITableViewDelegate{ func tableView(_ tableView: UITableView...