+= operator overloading
This commit is contained in:
parent
8613687eea
commit
e14317ba56
|
|
@ -184,4 +184,14 @@ extension TableDirector {
|
|||
|
||||
return invokeAction(.shouldHighlight, cell: tableView.cellForRowAtIndexPath(indexPath), indexPath: indexPath) as? Bool ?? true
|
||||
}
|
||||
}
|
||||
|
||||
public func +=(left: TableDirector, right: RowBuilder) {
|
||||
|
||||
left.appendSection(TableSectionBuilder(rowBuilders: [right]))
|
||||
}
|
||||
|
||||
public func +=(left: TableDirector, right: TableSectionBuilder) {
|
||||
|
||||
left.appendSection(right)
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ internal enum ActionHandler<I, C> {
|
|||
case actionBlock((data: ActionData<I, C>) -> Void)
|
||||
case actionReturnBlock((data: ActionData<I, C>) -> AnyObject?)
|
||||
|
||||
func call(data: ActionData<I, C>) -> AnyObject? {
|
||||
func invoke(data: ActionData<I, C>) -> AnyObject? {
|
||||
|
||||
switch (self) {
|
||||
case .actionBlock(let closure):
|
||||
|
|
@ -110,7 +110,7 @@ public class TableRowBuilder<I, C where C: UITableViewCell> : RowBuilder {
|
|||
public func invokeAction(actionType: ActionType, cell: UITableViewCell?, indexPath: NSIndexPath, itemIndex: Int) -> AnyObject? {
|
||||
|
||||
if let action = actions[actionType.key] {
|
||||
return action.call(ActionData(cell: cell as? C, indexPath: indexPath, item: items[itemIndex], itemIndex: itemIndex))
|
||||
return action.invoke(ActionData(cell: cell as? C, indexPath: indexPath, item: items[itemIndex], itemIndex: itemIndex))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -55,6 +55,6 @@ class ViewController: UIViewController {
|
|||
|
||||
let sectionBuilder = TableSectionBuilder(headerTitle: "Tablet", footerTitle: "Deal with table view like a boss.", rowBuilders: [rowBuilder, configurableRowBuilder])
|
||||
|
||||
tableDirector.appendSection(sectionBuilder)
|
||||
tableDirector += sectionBuilder
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue