Available thruCocoapods
Latest0.1
Homepagehttps://github.com/tuanphung/ReactiveTableView
LicenseMIT

Simply the way to display multiple cell types on TableView.

Requirements

  • iOS 8.0+ / Mac OS X 10.9+
  • Xcode 6.4

Installation

CocoaPods is a dependency manager for Cocoa projects.

CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:

$ gem install cocoapods

To integrate ReactiveTableView into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'ReactiveTableView', '~> 1.0'

Then, run the following command:

$ pod install

Usage

Prepare your TableViewCell

// Define a reuse identifier for your cell
public override class func reuseIdentifier() -> String { return "SimpleTableViewCell" }

// In case you load your cell from Xib, let it know name of Xib
public override class func nibName() -> String? { return "SimpleTableViewCell" }

// Caculate cell height, depending on model.
// UITableViewAutomaticDimension is default, which is dynamic cell height.
public override class func height(model: AnyObject) -> CGFloat { return UITableViewAutomaticDimension }

Configure cell to let it know how to populate data from model. Should cast type before using

public override func configureCell(model: AnyObject) {
  if let model = model as? SimpleCellModel {
    self.titleLabel.text = model.title
  }
}

Bind your cell type with model type. Unlimited how many bindings you can make.

tableView.bind(model: SimpleCellModel.self, toCell: SimpleTableViewCell.self)
tableView.bind(model: <YOUR_MODEL>.self, toCell: <YOUR_CELL>.self)

Then, just push items you want to display into table.

tableView.addItems([
  SimpleCellModel(title: "A"),
  SimpleCellModel(title: "B"),
  SimpleCellModel(title: "C"),
  SimpleCellModel(title: "D"),
  YOUR_MODEL()])

License

ReactiveTableView is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "ReactiveTableView",
    "version": "0.1",
    "summary": "Simply the way to display multiple cell types on TableView.",
    "description": "Remove the old way to display cell on TableView. Now you can link Cell class with Model class with `bind` method.nJust need to push models and see them displaying on TableView.",
    "homepage": "https://github.com/tuanphung/ReactiveTableView",
    "license": "MIT",
    "authors": {
        "Tuan Phung": "[email protected]"
    },
    "social_media_url": "https://twitter.com/tuanphunglk",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/tuanphung/ReactiveTableView.git",
        "tag": "0.1"
    },
    "source_files": "Source/*.swift",
    "requires_arc": true
}

Pin It on Pinterest

Share This