O'Reilly logo

iOS Programming Cookbook by Hossam Ghareeb

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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...

  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) 
              } 
          } 
     
    
  2. Add the following extension to implement the UITableViewDelegate protocol and override the editActionsForRow function:
          extension TasksListsViewController: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required