Skip to content
A lazy way for smart developers to deal with UITableView.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

#ATTableView A lazy way for smart developers to deal with UITableView.

Why ATTableView?

How many times do you have to implement UITableViewDatasource and UITableViewDelegate?
Is it boring? And how to deal with different UITableViewCells in one TableView?

You're smart, so you need a smart way to do it.
ATTableView is for you, it's easy to display model in UITableView. Also support different UITableViewCells.

Traditional way

![alt tag] (/Doc/Assets/OldWay.png)

Your ViewController has to:

  • Implement a lot of methods to adapt UITableViewDatasource and UITableViewDelegate.
  • Do some sucked things like if else condition if you need to display different UITableViewCells in one TableView.
  • Maintain models.
  • Hard to reuse UITableView.

Lazy way

![alt tag] (/Doc/Assets/LazyWay.png)

So now:

  • Don't need to implement any methods of UITableViewDatasource and UITableViewDelegate. Most should be done in UITableViewCell.
  • It's super easy to reuse UITableViewCell.
  • Models are managed by ATTableView, not ViewController anymore.
  • Allow displaying UITableViewCells base on model type without pain. After some setup, just push models to ATTableView, then cell will automatically pick up models and display them.
  • Support Generic and Associated types. So no type casts required.

Introduce ATTableViewCellProtocol

public protocol ATTableViewCellProtocol: NSObjectProtocol {
    typealias ModelType

    // Optional, default is ClassName
    static func reuseIdentifier() -> String

    // Optional, default is ClassName
    static func nibName() -> String?

    // Optional, default is `UITableViewAutomaticDimension`
    static func height(model: ModelType) -> CGFloat

    // Define how to map properties of model to UI.
    // This method must be implemented.
    func configureCell(model: ModelType)

ATTableView requires some implementations in your cell, so your cell must implement this protocol.

  • Don't need to implement all, some methods already have default implementation.
  • No type casts required. ModelType is based on your definition.

Sample Project

There's a sample project in the Demo directory. Or follow the instructions [here] (Doc/
Have fun!


After some setup, using ATTableView is really simple. In your ViewController, just follow these steps below:

1.Register your cells:


2.Push your models:

let restaurant = Restaurant()
... // Some extra initializions

let hotel = Hotel()
... // Some extra initializions

self.tableView.addObjects([restaurant, hotel])

3.Enjoy it!

alt tag

Handle click event on Cell

Just easy like this:

self.tableView.onDidSelectItem = { [weak self] item in
    // Handle selected item here

Lazy loading models from Network

Coming soon...


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


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 ATTableView into your Xcode project using CocoaPods, specify it in your Podfile:

source ''
platform :ios, '8.0'

pod 'ATTableView', '1.2'

Then, run the following command:

$ pod install


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

You can’t perform that action at this time.