Latest 1.0.2
Homepage https://github.com/GopherLabsLtd/SwiftyDequeuable
License MIT
Platforms ios 8.0
Authors

CocoaPods Compatible
Platform

SwiftyDequeuable is a a more Elegant way to dequeue cells with a UITableView or a UICollectionView.

With Swift, we have the power of Protocol Oriented Programming + Protocol Extensions and with using Generics we can simplify these redundant processes.

We go from…

override func viewDidLoad() {
     super.viewDidLoad()

     let nibName = UINib(nibName: "SimpleLabelCell", bundle:nil)
     tableView.registerNib(nibName, forCellReuseIdentifier: "SimpleLabelCell")
 }

To something a little more Elegant…

override func viewDidLoad() {
    super.viewDidLoad()

    tableView.registerNib(SimpleLabelCell.self)
}

No more strings!

Installation

Cocoapods

  pod 'SwiftyDequeuable'

Usage

Create a new cell with the corresponding .xib

import UIKit

class SimpleLabelCell: UITableViewCell {
    @IBOutlet weak var label: UILabel!
}

In your viewDidLoad register your cell (or where ever you usually register your cells)

override func viewDidLoad() {
    super.viewDidLoad()

    tableView.registerNib(SimpleLabelCell.self)
}

In your cellForRowAt of your UITableViewDatasource you can dequeue the cell by…

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  // If we cannot dequeue cell, a fatal error would be thrown.
  let cell = tableView.dequeueReusableCell(SimpleLabelCell.self, forIndexPath: indexPath)
  return cell
}

SwiftyDequeuable also supports UICollectionView, the steps are very to the ones above. Have a look at the Example.

License

SwiftyDequeuable is released under an MIT license. See License.md for more information.

Latest podspec

{
    "name": "SwiftyDequeuable",
    "version": "1.0.2",
    "summary": "A more simpler way to Dequeue Cells in Swift",
    "description": "SwiftyDequeuable uses Generics and Protocol Oriented Programming to simplify reusing cells.",
    "homepage": "https://github.com/GopherLabsLtd/SwiftyDequeuable",
    "license": {
        "type": "MIT",
        "file": "License.md"
    },
    "authors": {
        "Alex Nguyen": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/GopherLabsLtd/SwiftyDequeuable.git",
        "tag": "1.0.2"
    },
    "source_files": "Source/",
    "exclude_files": "Source/Exclude",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This