lundi 13 avril 2020

MVVM Design pattern implementation

I am asking for the implementation of MVVM Design pattern so here i have a HomeViewController

Which contains a HomeViewModel , HomeViewController has a tableView and some other UIKit components in MVVM i read that Every UIView should have its own ViewModel so for the cells of UITableView (HomeTableViewCell) each one should hase its own ViewModel , so should HomeViewModel contains A Collection of SubViewModels for the cells that will be passed to every cell or what is the right implementation of it , the best scenario?

extension HomeViewController : UITableViewDelegate , UITableViewDataSource{
    public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return viewModel?.articlesCount ?? 0
    }

    public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {


    }


}

Aucun commentaire:

Enregistrer un commentaire