diff --git a/Static/DataSource.swift b/Static/DataSource.swift index 4615319..f53a433 100644 --- a/Static/DataSource.swift +++ b/Static/DataSource.swift @@ -292,7 +292,7 @@ extension DataSource: UITableViewDelegate { } if let row = row(at: indexPath) { - row.selection?() + row.selection?(row) } tableViewDelegate?.tableView?(tableView, didSelectRowAt: indexPath) @@ -300,7 +300,7 @@ extension DataSource: UITableViewDelegate { public func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) { if let row = row(at: indexPath) { - row.accessory.selection?() + row.accessory.selection?(row) } tableViewDelegate?.tableView?(tableView, accessoryButtonTappedForRowWith: indexPath) diff --git a/Static/Row.swift b/Static/Row.swift index 4909870..c11176b 100644 --- a/Static/Row.swift +++ b/Static/Row.swift @@ -1,7 +1,7 @@ import UIKit /// Row or Accessory selection callback. -public typealias Selection = () -> Void +public typealias Selection = (Row) -> Void public typealias ValueChange = (Bool) -> () public typealias SegmentedControlValueChange = (Int, Any?) -> () diff --git a/Static/Tests/DataSourceTests.swift b/Static/Tests/DataSourceTests.swift index 67664f5..4772e26 100644 --- a/Static/Tests/DataSourceTests.swift +++ b/Static/Tests/DataSourceTests.swift @@ -92,14 +92,14 @@ class DataSourceTests: XCTestCase { XCTAssertFalse(dataSource.tableView(tableView, shouldHighlightRowAt: IndexPath(row: 0, section: 0))) dataSource.sections = [ - Section(rows: [Row(text: "Cupcakes", selection: {})]) + Section(rows: [Row(text: "Cupcakes", selection: { (row) in })]) ] XCTAssertTrue(dataSource.tableView(tableView, shouldHighlightRowAt: IndexPath(row: 0, section: 0))) } func testSelection() { let expectation = self.expectation(description: "Selected") - let selection = { + let selection: Selection = { (row) in expectation.fulfill() } @@ -112,7 +112,7 @@ class DataSourceTests: XCTestCase { func testAccessorySelection() { let expectation = self.expectation(description: "Accessory Selected") - let selection = { + let selection: Selection = { (row) in expectation.fulfill() } diff --git a/Static/Tests/RowTests.swift b/Static/Tests/RowTests.swift index 2cc9c7a..2979ed6 100644 --- a/Static/Tests/RowTests.swift +++ b/Static/Tests/RowTests.swift @@ -4,7 +4,7 @@ import Static class RowTests: XCTestCase { func testInit() { - let selection: Selection = {} + let selection: Selection = { (row) in } let context: Row.Context = [ "Hello": "world" ] @@ -36,7 +36,7 @@ class RowTests: XCTestCase { } func testInitWithSelectableAccessoryType() { - let selection: Selection = {} + let selection: Selection = { (row) in } let accessory: Row.Accessory = .detailButton(selection) let row = Row(accessory: accessory)