Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. extension UITableView {
  2.  
  3. public func dequeue<T: UITableViewCell>(cellClass: T.Type) -> T? {
  4. return dequeueReusableCell(withIdentifier: cellClass.reuseIdentifier) as? T
  5. }
  6.  
  7. public func dequeue<T: UITableViewCell>(cellClass: T.Type, forIndexPath indexPath: IndexPath) -> T {
  8. guard let cell = dequeueReusableCell(
  9. withIdentifier: cellClass.reuseIdentifier, for: indexPath) as? T else {
  10. fatalError(
  11. "Error: cell with id: \(cellClass.reuseIdentifier) for indexPath: \(indexPath) is not \(T.self)")
  12. }
  13. return cell
  14. }
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement