// // UITableView+Extensions.swift // OpenSourceControllerDemo // // Created by Florian Gabach on 10/12/2018. // Copyright © 2018 OpenSourceController. All rights reserved. // import UIKit extension UITableView { open func register(cellType: T.Type) where T: Reusable { self.register(cellType.self, forCellReuseIdentifier: cellType.reuseIdentifier) } open func dequeueReusableCell(for indexPath: IndexPath, cellType: T.Type = T.self) -> T where T: Reusable { guard let cell = self.dequeueReusableCell(withIdentifier: cellType.reuseIdentifier, for: indexPath) as? T else { fatalError( "Failed to dequeue a cell with identifier \(cellType.reuseIdentifier) matching type \(cellType.self). " + "Check that the reuseIdentifier is set properly in your XIB/Storyboard " + "and that you registered the cell beforehand" ) } return cell } }