From b74403e2c62fc99aa3488015bb893af79b3dea8a Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Sat, 15 Oct 2016 11:09:48 +0300 Subject: [PATCH] add removeAction method --- Sources/TableRow.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift index 67d268f..c11eae5 100644 --- a/Sources/TableRow.swift +++ b/Sources/TableRow.swift @@ -56,6 +56,7 @@ open class TableRow: Row where CellType: UITableView // MARK: - RowConfigurable - open func configure(_ cell: UITableViewCell) { + (cell as? CellType)?.configure(with: item) } @@ -67,6 +68,7 @@ open class TableRow: Row where CellType: UITableView } open func hasAction(_ action: TableRowActionType) -> Bool { + return actions[action.key] != nil } @@ -97,11 +99,20 @@ open class TableRow: Row where CellType: UITableView return on(TableRowAction(type, handler: handler)) } - func removeAllActions() { + open func removeAllActions() { actions.removeAll() } + open func removeAction(forActionId actionId: String) { + + for (key, value) in actions { + if let actionIndex = value.index(where: { $0.id == actionId }) { + actions[key]?.remove(at: actionIndex) + } + } + } + // MARK: - deprecated actions - @available(*, deprecated, message: "Use 'on' method instead")