Created
June 1, 2016 18:22
-
-
Save FlorianBasso/0fd5edc185eb6af6cc79521e644b0956 to your computer and use it in GitHub Desktop.
Cell Item Protocol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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