Fri. Apr 19th, 2024
override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]?
    {
        let deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.default, title: "Löschen" , handler: { (action:UITableViewRowAction, indexPath: IndexPath) -> Void in
            let deleteMenu = UIAlertController(title: nil, message: "Wirklich Löschen?", preferredStyle: .actionSheet)
            let deleteAction = UIAlertAction(title: "Ja", style: UIAlertActionStyle.default) { _ in // crazy closure!
                self.audits.remove(at: indexPath.item)
                Storage.store(self.audits, to: .documents, as: "runningAudit.json") // store audit
                tableView.reloadData()
            }
            let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel, handler: nil)
            deleteMenu.addAction(deleteAction)
            deleteMenu.addAction(cancelAction)
            self.present(deleteMenu, animated: true, completion: nil)
        })
        return [deleteAction]
    }

By rams

Leave a Reply

Your email address will not be published. Required fields are marked *