override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
let apDelegate = UIApplication.shared.delegate as! AppDelegate
let context = apDelegate.persistentContainer.viewContext
let fetchRequest: NSFetchRequest<Task> = Task.fetchRequest()
guard editingStyle == .delete else { return }
if let objArray = try? context.fetch(fetchRequest) {
let object = objArray[indexPath.row]
context.delete(object)
}
do {
try
context.save()
tableView.deleteRows(at: [indexPath], with: .automatic)
} catch let error as NSError {
print("Error: \(error), deskription \(error.userInfo)")
}
}