// // UICollectionView+Identifiable.swift // Bio // // Created by Joan Disho on 22.07.18. // Copyright © 2018 Joan Disho. All rights reserved. // import UIKit extension UICollectionView { func register(cellType: C.Type) where C: ClassIdentifiable { register(cellType.self, forCellWithReuseIdentifier: cellType.reuseId) } func register(cellType: C.Type) where C: NibIdentifiable & ClassIdentifiable { register(cellType.nib, forCellWithReuseIdentifier: cellType.reuseId) } func dequeueReusableCell(withCellType type: C.Type = C.self, forIndexPath indexPath: IndexPath) -> C where C: ClassIdentifiable { guard let cell = dequeueReusableCell(withReuseIdentifier: type.reuseId, for: indexPath) as? C else { fatalError("Couldn't dequeue a UICollectionViewCell with identifier: \(type.reuseId)") } return cell } }