diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index a0c0e9e..4bdf9c0 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -71,7 +71,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { @discardableResult open func invoke(action: TableRowActionType, cell: UITableViewCell?, indexPath: IndexPath) -> Any? { - return sections[indexPath.section].rows[indexPath.row].invoke(action, cell: cell, path: indexPath) + return sections[indexPath.section].rows[indexPath.row].invoke(action: action, cell: cell, path: indexPath) } open override func responds(to selector: Selector) -> Bool { @@ -85,7 +85,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { // MARK: - Internal - func hasAction(_ action: TableRowActionType, atIndexPath indexPath: IndexPath) -> Bool { - return sections[indexPath.section].rows[indexPath.row].hasAction(action) + return sections[indexPath.section].rows[indexPath.row].has(action: action) } func didReceiveAction(_ notification: Notification) { diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift index cf3ec49..420cceb 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -30,8 +30,8 @@ public protocol RowActionable { var editingActions: [UITableViewRowAction]? { get } func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool - func invoke(_ action: TableRowActionType, cell: UITableViewCell?, path: IndexPath) -> Any? - func hasAction(_ action: TableRowActionType) -> Bool + func invoke(action: TableRowActionType, cell: UITableViewCell?, path: IndexPath) -> Any? + func has(action: TableRowActionType) -> Bool } public protocol RowHashable { diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift index c11eae5..5e6b607 100644 --- a/Sources/TableRow.swift +++ b/Sources/TableRow.swift @@ -62,12 +62,12 @@ open class TableRow: Row where CellType: UITableView // MARK: - RowActionable - - open func invoke(_ action: TableRowActionType, cell: UITableViewCell?, path: IndexPath) -> Any? { + open func invoke(action: TableRowActionType, cell: UITableViewCell?, path: IndexPath) -> Any? { return actions[action.key]?.flatMap({ $0.invokeActionOn(cell: cell, item: item, path: path) }).last } - open func hasAction(_ action: TableRowActionType) -> Bool { + open func has(action: TableRowActionType) -> Bool { return actions[action.key] != nil } @@ -75,7 +75,7 @@ open class TableRow: Row where CellType: UITableView open func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool { if actions[TableRowActionType.canEdit.key] != nil { - return invoke(.canEdit, cell: nil, path: indexPath) as? Bool ?? false + return invoke(action: .canEdit, cell: nil, path: indexPath) as? Bool ?? false } return editingActions?.isEmpty == false || actions[TableRowActionType.clickDelete.key] != nil }