Last active
April 11, 2022 01:03
-
-
Save hsleedevelop/4a18e86705b5d62685d791b76f928fea to your computer and use it in GitHub Desktop.
Using Generics to simplify subclassing UIViewController’s view
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
//refs: https://codeinswift.io/using-generics-to-simplify-subclassing-uiviewcontrollers-view-860c90852e27 | |
class ViewController<UI: UIView>: UIViewController { | |
let ui = UI(frame: UIScreen.main.bounds) | |
override func loadView() { | |
self.view = ui | |
} | |
} | |
class ProductsListViewController: ViewController<ProductsListView> { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
ui.tableView.reloadData() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment