From 94aacbcbe3348e20bd40fba866271b4b4687ec5f Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Sun, 8 Nov 2015 20:03:35 +0300 Subject: [PATCH] bump readme --- README.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a23f7e4..d792852 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Tablet is a super lightweight yet powerful library that handles a complexity of ## Requirements -- iOS 7.0+ +- iOS 8.0+ - Xcode 7.0+ ## Usage @@ -30,6 +30,7 @@ director.appendSections(sectionBuilder) ### Additional cell actions ```swift +import Tablet let rowBuilder = TableRowBuilder(items: [user1, user2, user3], id: "reusable_id") .action(.configure) { data in @@ -41,4 +42,37 @@ let rowBuilder = TableRowBuilder(items: [user1, user2, us .action(.willDisplay) { data in } +``` + +### Configurable cells + +Let's say you want to put your cell configuration logic into cell itself. Say you want to pass your view model (or even model) to your cell. +To provide this behaviour simply follow: + +```swift +import Tablet + +class UserTableViewCell : UITableViewCell, ConfigurableCell { + + typealias Item = User + + static func reusableIdentifier() -> String { + return "reusable_id" + } + + func configureWithItem(item: Item) { // item is user here + + textLabel?.text = item.title + detailTextLabel?.text = item.isActive ? "Active" : "Inactive" + } +} +``` +Once you follow the protocol, simply use TableConfigurableRowBuilder to build cells: + +```swift +import Tablet + +let rowBuilder = TableConfigurableRowBuilder() + +tableDirector.appendSection(TableSectionBuilder(rowBuilders: [rowBuilder])) ``` \ No newline at end of file