Skip to content

Instantly share code, notes, and snippets.

@bigimot22
Created February 2, 2019 08:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigimot22/ac45a2097cb073fc3f5eac89f81a1e59 to your computer and use it in GitHub Desktop.
Save bigimot22/ac45a2097cb073fc3f5eac89f81a1e59 to your computer and use it in GitHub Desktop.
Cool way to dequeue reusable Tableview cells.
import UIKit
extension UITableView {
func dequeueReusableCell<T: UITableViewCell>() -> T {
return dequeueReusableCell(withIdentifier: NSStringFromClass(T.self)) as! T
}
}
//To use it, you declare a cell as follow:
// let cell: ExampleTableViewCell = tableView.dequeueReusableCell()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment