diff --git a/Tablet/TableDirector.swift b/Tablet/TableDirector.swift index daacd4c..28379b1 100644 --- a/Tablet/TableDirector.swift +++ b/Tablet/TableDirector.swift @@ -73,6 +73,20 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate builder.0.invokeAction(.custom(action.key), cell: action.cell, indexPath: indexPath, itemIndex: builder.1) } } + + func registerNibs() { + + let bundle = NSBundle(forClass: UITableViewCell.self) + + if let _ = bundle.pathForResource("cell name", ofType: "nib") { // existing cell + + tableView.registerNib(UINib(nibName: "", bundle: bundle), forCellReuseIdentifier: "") + + } else { + + tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "") + } + } } extension TableDirector { diff --git a/Tablet/TableRowBuilder.swift b/Tablet/TableRowBuilder.swift index 390e668..9d1b418 100644 --- a/Tablet/TableRowBuilder.swift +++ b/Tablet/TableRowBuilder.swift @@ -141,4 +141,10 @@ public extension TableRowBuilder { items.removeAll() } +} + +public func +=(var left: TableRowBuilder, right: T) -> TableRowBuilder { + + left.appendItems([right]) + return left } \ No newline at end of file diff --git a/TabletDemo/TabletDemo.xcodeproj/project.xcworkspace/xcuserdata/maxsokolov.xcuserdatad/UserInterfaceState.xcuserstate b/TabletDemo/TabletDemo.xcodeproj/project.xcworkspace/xcuserdata/maxsokolov.xcuserdatad/UserInterfaceState.xcuserstate index fe73904..128e146 100644 Binary files a/TabletDemo/TabletDemo.xcodeproj/project.xcworkspace/xcuserdata/maxsokolov.xcuserdatad/UserInterfaceState.xcuserstate and b/TabletDemo/TabletDemo.xcodeproj/project.xcworkspace/xcuserdata/maxsokolov.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/TabletDemo/TabletDemo/ViewController.swift b/TabletDemo/TabletDemo/ViewController.swift index af228c3..786811e 100644 --- a/TabletDemo/TabletDemo/ViewController.swift +++ b/TabletDemo/TabletDemo/ViewController.swift @@ -18,7 +18,7 @@ class ViewController: UIViewController { tableDirector = TableDirector(tableView: tableView) - let rowBuilder = TableRowBuilder(items: [1, 2, 3, 4], id: "cell") + var rowBuilder = TableRowBuilder(items: [1, 2, 3, 4], id: "cell") .action(.configure) { data in data.cell?.textLabel?.text = "\(data.item)" @@ -52,6 +52,8 @@ class ViewController: UIViewController { data.cell!.contentLabel.text = "Tablet is a super lightweight yet powerful generic library that handles a complexity of UITableView's datasource and delegate methods in a Swift environment. Tablet's goal is to provide an easiest way to create complex table views. With Tablet you don't have to write a messy code of switch or if statements when you deal with bunch of different cells in different sections." } + + //rowBuilder += rowBuilder let sectionBuilder = TableSectionBuilder(headerTitle: "Tablet", footerTitle: "Deal with table view like a boss.", rowBuilders: [rowBuilder, configurableRowBuilder])