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.
Updating and deleting records from Core Data
How to do it...
- 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...