Skip to content

Instantly share code, notes, and snippets.

@bobleesj
Created December 28, 2016 15:12
Show Gist options
  • Save bobleesj/8110339d55557e1958333c4c34e2ca47 to your computer and use it in GitHub Desktop.
Save bobleesj/8110339d55557e1958333c4c34e2ca47 to your computer and use it in GitHub Desktop.
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
let task = tasks[indexPath.row]
context.delete(task)
(UIApplication.shared.delegate as! AppDelegate).saveContext()
do {
tasks = try context.fetch(Task.fetchRequest())
} catch {
print("Fetching Failed")
}
}
tableView.reloadData()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment