Skip to content

Instantly share code, notes, and snippets.

View chu-yik's full-sized avatar
🇨🇦

Yik Chu chu-yik

🇨🇦
View GitHub Profile
@chu-yik
chu-yik / ios-cell-registration-swift.md
Last active March 1, 2020 04:02 — forked from andreaantonioni/ios-cell-registration-swift.md
iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

A common task when developing iOS apps is to register custom cell subclasses for both UITableView and UICollectionView. Well, that is if you don’t use Storyboards, of course.

Both UITableView and UICollectionView offer a similar API to register custom cell classes:

for UITableView

public func register(_ cellClass: AnyClass?, forCellReuseIdentifier identifier: String)
public func register(_ nib: UINib?, forCellReuseIdentifier identifier: String)