iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics
Guille Gonzalez
36118

This is a really nice idea! I’m using it now, but there’s a small change required so that all your concrete cell subclasses don’t have to implement the protocol explicitly.

extension ReusableView where Self: UIView {

static var defaultReuseIdentifier: String {

// Lowercase `self` is important! Using `Self` always returns `”UICollectionViewCell”` or `”UITableViewCell”`.

return String(self)

}

}

Show your support

Clapping shows how much you appreciated Sami Samhuri’s story.