CoreData: Delete Data

In a tableview:

        let itemToDelete = people[indexPath.row]

    print(itemToDelete)

    if (editingStyle == UITableViewCellEditingStyle.delete) {
        // handle delete (by removing the data from your array and updating the tableview)

        persistenceService.context.delete(itemToDelete)
        self.people.remove(at: indexPath.row)

        do {
            try persistenceService.context.save()
        } catch let error as NSError {
            print("Error While Deleting: \(error.userInfo)")
        }


    }