Latest 1.1.0
License MIT
Platforms ios 8.0, requires ARC

Generic Cell Controllers

GenericCellControllers is a Swift framework that simplifies dealing with [heterogeneous] lists of data in a UITableView or UICollectionView. Its main goal is to reduce boilerplate and to let you focus on the important bits of your feature.


You can find all about the process that led us to create GenericCellControllers in our blog.


  • Handles all boilerplate letting you focus on your features.
  • Uses generics to adapt to your types. No need to downcast in your code.
  • Highly flexible and expandable.
  • Unified API for UITableView and UICollectionView.
  • Compiler time checks. Helps you detect mistakes ahead of time.

How to use

The best way to learn how to use it is to read our blogposts or have a look at the provided example project.

A quick summary would be:

  1. Subclass GenericCellController and implement the methods you require (all of them are optional).
    import GenericCellControllers

class MyCellController: GenericCellController {
func configureCell(_ cell: MyCell) {
// Your configuration code…

func cellSelected() {
    // Action to execute when the cell is selected...


2. Register your cell controllers in your `UITableView` or `UICollectionView`.
MyCellController.registerCell(on: tableView)
MyOtherCellController.registerCell(on: tableView)
  1. Create your list of cell controllers that matches your list of [heterogeneous] data.
    import GenericCellControllers

class MyTableController: UITableViewDataSource, UITableViewDelegate {
var tableView: UITableView!
var cellControllers: [TableCellController] = []

func updateTableView() {
cellControllers = createCellControllers()
tableView.delegate = self
tableView.dataSource = self

For points **2** and **3** we recommend the use of the [Factory pattern](

4. Forward the relevant *delegate* and *datasource* methods to the Cell Controllers.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    return cellControllers[indexPath.row].cellFromReusableCellHolder(tableView, forIndexPath: indexPath)

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

Again, refer to our blog (by now you may have figured out that you should really read it 😜) or have a look at the example project for more details.

Variable IndexPaths

The GenericCellControllers use the IndexPath they are sent while dequeuing cells to be able to locate that cell in other methods, like currentCell(). If you insert or delete cells in your UITableView or UICollectionView without reloading it, remember to manually update the IndexPath of the Cell Controllers that may be affected.

How to install


  1. Make sure use_frameworks! is added to your Podfile.
  2. Include the following in your Podfile:
    pod 'GenericCellControllers'
  3. Run pod install.


    Simply add GenericCellControllers to your Cartfile:

    github "Busuu/generic-cell-controllers"


  4. Clone, add as a submodule or download.
  5. Drag and drop GenericCellControllers project to your workspace.
  6. Add GenericCellControllers to Embedded binaries.


    Source code is distributed under MIT license.

Latest podspec

    "name": "GenericCellControllers",
    "version": "1.1.0",
    "summary": "Framework that makes it easier to work with heterogeneous lists of data in iOS.",
    "description": "Generic Cell Controllers provide protocols, implementations and extensions that will make worknwith heterogeneous lists of data in iOS really easy. It provides a way to abstract the details nof each particular cell configuration and management away from the View Controllers, Data nSources and Delegates.",
    "homepage": "",
    "license": {
        "type": "MIT"
    "authors": {
        "Javier Valdera": "[email protected]"
    "platforms": {
        "ios": "8.0"
    "source": {
        "git": "",
        "tag": "1.1.0"
    "source_files": "GenericCellControllers/Source/**/*.{h,m,swift}",
    "public_header_files": "GenericCellControllers/Source/**/*.h",
    "requires_arc": true,
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.0"

Pin It on Pinterest

Share This