sections now keep reference to director instead of table view
This commit is contained in:
parent
0e42c836c1
commit
6498e39daa
|
|
@ -185,7 +185,7 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
|
|||
|
||||
public func append(sections sections: [TableSectionBuilder]) {
|
||||
|
||||
sections.forEach { $0.willMoveToDirector(tableView) }
|
||||
sections.forEach { $0.tableDirector = self }
|
||||
self.sections.appendContentsOf(sections)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,14 @@ import Foundation
|
|||
Can host several row builders.
|
||||
*/
|
||||
public class TableSectionBuilder {
|
||||
|
||||
weak var tableDirector: TableDirector? {
|
||||
didSet {
|
||||
guard let director = tableDirector else { return }
|
||||
builders.forEach { $0.registerCell(inTableView: director.tableView) }
|
||||
}
|
||||
}
|
||||
|
||||
weak var tableView: UITableView?
|
||||
private var builders = [RowBuilder]()
|
||||
|
||||
public var headerTitle: String?
|
||||
|
|
@ -74,7 +80,7 @@ public class TableSectionBuilder {
|
|||
|
||||
public func append(rows rows: [RowBuilder]) {
|
||||
|
||||
if let tableView = tableView { rows.forEach { $0.registerCell(inTableView: tableView) } }
|
||||
if let tableView = tableDirector?.tableView { rows.forEach { $0.registerCell(inTableView: tableView) } }
|
||||
builders.appendContentsOf(rows)
|
||||
}
|
||||
|
||||
|
|
@ -92,12 +98,6 @@ public class TableSectionBuilder {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func willMoveToDirector(tableView: UITableView) {
|
||||
|
||||
self.tableView = tableView
|
||||
self.builders.forEach { $0.registerCell(inTableView: tableView) }
|
||||
}
|
||||
}
|
||||
|
||||
public func +=(left: TableSectionBuilder, right: RowBuilder) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue