ViewController-View Generic Snippet

hsleedevelop·2022년 4월 11일
0

Snippet

목록 보기
1/1

//source: 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()
}
profile
software engineer

0개의 댓글