add removeAllActions method

This commit is contained in:
Max Sokolov 2016-10-15 01:19:48 +03:00
parent 0af6956d62
commit c040613654
3 changed files with 13 additions and 3 deletions

View File

@ -34,11 +34,16 @@ class MainController: UIViewController {
break
}
}
let printClickAction = TableRowAction<ConfigurableTableViewCell>(.click) { (data) in
print("click", data.indexPath)
}
let rows = [
TableRow<ConfigurableTableViewCell>(item: "Autolayout cells", actions: [clickAction]),
TableRow<ConfigurableTableViewCell>(item: "Nib cells", actions: [clickAction])
TableRow<ConfigurableTableViewCell>(item: "Autolayout cells", actions: [clickAction, printClickAction]),
TableRow<ConfigurableTableViewCell>(item: "Nib cells", actions: [clickAction, printClickAction])
]
// automatically creates a section, also could be used like tableDirector.append(rows: rows)

View File

@ -97,6 +97,11 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
return on(TableRowAction<CellType>(type, handler: handler))
}
func removeAllActions() {
actions.removeAll()
}
// MARK: - deprecated actions -
@available(*, deprecated, message: "Use 'on' method instead")

View File

@ -171,7 +171,7 @@ class TabletTests: XCTestCase {
let expectation = self.expectation(description: "cell action")
let row = TableRow<TestTableViewCell>(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")