Hi Everyone,
I built an app that has a detailViewController with a tableView on it. It has a cell and 1 Field Label and 1 Value Label. When I tap to view the detailViewController it will populate what was previously added and saved. I am using CoreData to fetch the data to the detailViewController. My question is how can i make it so if after tapping on a saved job and opening that job in the detailViewController "Editable" there are 21 rows that populate. Ive tried everything I can find in the forums but no luck so far. I managed to be able to delete a row, but cannot edit a row. Below is the code for the delete action. I removed the Edit part of the UISwipeActions. If anyone can help it would be greatly appreciated
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let deleteAction = UIContextualAction(style: .destructive, title: "Delete") { (action, Sourceview, completionHandler) in
if let appDelegate = (UIApplication.shared.delegate as? AppDelegate) {
let context = appDelegate.persistentContainer.viewContext
let inspectionsToDelete = self.fetchResultController.object(at: indexPath)
context.delete(inspectionsToDelete)
appDelegate.saveContext()
}
completionHandler(true)
}
let swipeActions = UISwipeActionsConfiguration(actions: [deleteAction])
return swipeActions
}
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
if searchController.isActive {
return false
} else {
return true
}
}
func deleteData(at indexPath: IndexPath) {
print(indexPath.row)
}
func editData(at indexPath: IndexPath) {
print(indexPath.row)
}