Last active
June 29, 2022 06:50
-
-
Save paigeshin/1810a211da7b22e3258b7ef9e88366f0 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 { | |
| func register(_ type: UITableViewCell.Type) { | |
| let className = String(describing: type) | |
| register(UINib(nibName: className, bundle: nil), forCellReuseIdentifier: className) | |
| } | |
| func dequeueReusableCell<T>(_ type: T.Type) -> T? { | |
| let className = String(describing: type) | |
| return dequeueReusableCell(withIdentifier: className) as? T | |
| } | |
| } | |
| tableView.register(MyCell.self) | |
| tableView.dequeueReusableCell(MyCell.self)! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment