Skip to content

Instantly share code, notes, and snippets.

@bobleesj
Created December 28, 2016 15:12
Show Gist options
  • Save bobleesj/707feb93723aa9fefb3ca004cdf8d062 to your computer and use it in GitHub Desktop.
Save bobleesj/707feb93723aa9fefb3ca004cdf8d062 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