CellRegistration 1.4.0

CellRegistration 1.4.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2017
SwiftSwift Version 4.0
SPMSupports SPM

Maintained by Grzegorz Krukowski.



  • By
  • Grzegorz Krukowski

CellRegistration

One line to rule them all

One-liner replacement for registering, dequeuing, casting cells for UITableView and UICollectionView

Instead of:

tableView.register(MyCustomCell.self, forCellReuseIdentifier: "MyCustomCell")
let cell : MyCustomCell = tableView.dequeueReusableCell(withIdentifier: "MyCustomCell", for: indexPath) as! MyCustomCell

you can now do only:

let : MyCustomCell = tableView.dequeueReusableCell(forIndexPath: indexPath)

No code refacotring needed, you can use that with existing projects that uses old-way. No need to worry about any registering, reuse identifiers, casting any more.

Cells loaded from nib files

Regardless the type of cell (loaded from code, or loaded from nib file), code is always the same:

Only requirement is to make a xib file with the same name as a class name.

let : MyCustomCell = tableView.dequeueReusableCell(forIndexPath: indexPath)
let : MyCustomCellLoadedFromXib = tableView.dequeueReusableCell(forIndexPath: indexPath)

or

tableView.dequeueReusableCell(forIndexPath: indexPath) as MyCustomCell
tableView.dequeueReusableCell(forIndexPath: indexPath) as MyCustomCellLoadedFromXib

This pod will search for a xib file that matches class name and register this nib automatically, otherwise it registers cell by class name.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

CellRegistration is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "CellRegistration"

Author

Grzegorz Krukowski, [email protected]

License

CellRegistration is available under the MIT license. See the LICENSE file for more info.