diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift index 7cb6d6e..30681d9 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -30,6 +30,7 @@ public protocol RowActionable { var editingActions: [UITableViewRowAction]? { get } func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool + func on(anyAction action: RowAction) -> Self func invoke(action: TableRowActionType, cell: UITableViewCell?, path: IndexPath, userInfo: [AnyHashable: Any]?) -> Any? func has(action: TableRowActionType) -> Bool } diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift index 26b7360..d23c7f2 100644 --- a/Sources/TableRow.swift +++ b/Sources/TableRow.swift @@ -84,13 +84,8 @@ open class TableRow: Row where CellType: UITableView @discardableResult open func on(_ action: TableRowAction) -> Self { - - if actions[action.type.key] == nil { - actions[action.type.key] = [RowAction]() - } - actions[action.type.key]?.append(action) - return self + return on(anyAction: action) } @discardableResult @@ -99,6 +94,17 @@ open class TableRow: Row where CellType: UITableView return on(TableRowAction(type, handler: handler)) } + @discardableResult + open func on(anyAction action: RowAction) -> Self { + + if actions[action.type.key] == nil { + actions[action.type.key] = [RowAction]() + } + actions[action.type.key]?.append(action) + + return self + } + open func removeAllActions() { actions.removeAll()