Latest 2.1.1
License MIT
Platforms ios 9.0

Swift Struct to dynamically hide and show UITableView Rows by name. This is written in Swift 3.

Includes sample app.


  • Cocoapods
  • Include TableViewHelper.swift in your project


Instantiate a copy of the class with a reference to the tableView:

helper = TableViewHelper(tableView:tableView)

Add all cells that can show to the helper giving each cell a name (multiple cells can have the same name):

helper.addCell(section: 0, cell: tableView.dequeueReusableCellWithIdentifier("S0R0")! as UITableViewCell, name: "S0R0")
helper.addCell(section: 0, cell: tableView.dequeueReusableCellWithIdentifier("S0R1")! as UITableViewCell, name: "S0R1")

helper.addCell(section: 1, cell: tableView.dequeueReusableCellWithIdentifier("S1R0")! as UITableViewCell, name: "S1R0")

Reference the helper class for relevant UITableView calls:

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return helper.numberOfSections()

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return helper.numberOfRows(in: section)

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    return helper.cellForRow(at: indexPath)

Hide or show cells by name (if multiple cells have the same name, then all with that name are shown or hidden):


All public methods

func addCell(section:Int, cell:UITableViewCell, name:String, isInitiallyHidden: Bool = false)

func hideInitiallyHiddenCells()
func hideCell(_ name:String)
func showCell(_ name:String)

func cellName(at indexPath:NSIndexPath) -> String?
func indexPathForCell(_ name:String) -> NSIndexPath? // first matching cell
func indexPathsForCell(_ name:String) -> [NSIndexPath]
func visibleCells(_ name:String) -> [UITableViewCell]
func cellIsVisible(_ name:String) -> Bool // // returns true if ALL cells with that name are visible

func numberOfSections() -> Int
func numberOfRows(inSection section: Int) -> Int
func cellForRow(at indexPath: NSIndexPath) -> UITableViewCell

Latest podspec

    "name": "TableViewHelper",
    "version": "2.1.1",
    "summary": "Easily hide and show UITableView Rows",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Aaron Bratcher": "[email protected]"
    "social_media_url": "",
    "platforms": {
        "ios": "9.0"
    "source": {
        "git": "",
        "tag": "2.1.1"
    "source_files": [
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This