Created
April 11, 2019 08:14
-
-
Save BeauNouvelle/0d18cb0fd861ba0442abb6894c0c6c56 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
extension UITableView { | |
public func dequeue<T: UITableViewCell>(cellClass: T.Type) -> T? { | |
return dequeueReusableCell(withIdentifier: cellClass.reuseIdentifier) as? T | |
} | |
public func dequeue<T: UITableViewCell>(cellClass: T.Type, forIndexPath indexPath: IndexPath) -> T { | |
guard let cell = dequeueReusableCell( | |
withIdentifier: cellClass.reuseIdentifier, for: indexPath) as? T else { | |
fatalError( | |
"Error: cell with id: \(cellClass.reuseIdentifier) for indexPath: \(indexPath) is not \(T.self)") | |
} | |
return cell | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment