Skip to content

Instantly share code, notes, and snippets.

@FlorianBasso
Created June 1, 2016 18:22
Show Gist options
  • Save FlorianBasso/0fd5edc185eb6af6cc79521e644b0956 to your computer and use it in GitHub Desktop.
Save FlorianBasso/0fd5edc185eb6af6cc79521e644b0956 to your computer and use it in GitHub Desktop.
Cell Item Protocol
protocol CellItem {
func reuseIdentifier() -> String
func cellNib() -> UINib?
func configureCell(cell: UICollectionViewCell)
func cellSize(maxSize: CGSize) -> CGSize
func register(collectionView: UICollectionView)
}
extension CellItem {
func register(collectionView: UICollectionView) {
let nib = self.cellNib()
let reuseIdentifier = self.reuseIdentifier()
collectionView.registerNib(nib, forCellWithReuseIdentifier: reuseIdentifier)
}
func cellNib() -> UINib? {
return UINib(nibName: self.reuseIdentifier(), bundle: NSBundle.mainBundle())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment