From c0406136543109aed4c09eba00b240bfd54f957f Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Sat, 15 Oct 2016 01:19:48 +0300 Subject: [PATCH] add removeAllActions method --- .../Presentation/Controllers/MainController.swift | 9 +++++++-- Sources/TableRow.swift | 5 +++++ Tests/TableKitTests.swift | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Demo/Classes/Presentation/Controllers/MainController.swift b/Demo/Classes/Presentation/Controllers/MainController.swift index 7c0afdd..3cdf176 100644 --- a/Demo/Classes/Presentation/Controllers/MainController.swift +++ b/Demo/Classes/Presentation/Controllers/MainController.swift @@ -34,11 +34,16 @@ class MainController: UIViewController { break } } + + let printClickAction = TableRowAction(.click) { (data) in + + print("click", data.indexPath) + } let rows = [ - TableRow(item: "Autolayout cells", actions: [clickAction]), - TableRow(item: "Nib cells", actions: [clickAction]) + TableRow(item: "Autolayout cells", actions: [clickAction, printClickAction]), + TableRow(item: "Nib cells", actions: [clickAction, printClickAction]) ] // automatically creates a section, also could be used like tableDirector.append(rows: rows) diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift index bcb0df1..67d268f 100644 --- a/Sources/TableRow.swift +++ b/Sources/TableRow.swift @@ -97,6 +97,11 @@ open class TableRow: Row where CellType: UITableView return on(TableRowAction(type, handler: handler)) } + func removeAllActions() { + + actions.removeAll() + } + // MARK: - deprecated actions - @available(*, deprecated, message: "Use 'on' method instead") diff --git a/Tests/TableKitTests.swift b/Tests/TableKitTests.swift index 014cf4d..1ac4b01 100644 --- a/Tests/TableKitTests.swift +++ b/Tests/TableKitTests.swift @@ -171,7 +171,7 @@ class TabletTests: XCTestCase { let expectation = self.expectation(description: "cell action") let row = TableRow(item: TestData(title: "title")) - .action(TableRowAction(.custom(TestTableViewCellOptions.CellAction)) { (data) in + .on(TableRowAction(.custom(TestTableViewCellOptions.CellAction)) { (data) in XCTAssertNotNil(data.cell, "Action data should have a cell")