samedi 25 juin 2016

Creating view-model for UITableViewCell

I'm stuck on a design decision with creating view-model for table view's cells. Data for each cell is provided by a data source class (has an array of Contacts). In MVVM only view-model can talk to model, but it doesn't make sense to put data source in view-model because it would make possible to access data for all cells, also it's wrong to put data source in view controller as it must not have reference to the data. There are some other key moments:

  • Each cell must have it's own instance of view-model not a shared one
  • cellForRowAtindexPath must not be placed in a view-model because it shouldn't contain any UI references
  • View/ViewController's view-model should not interact with cell's view-model

What's the right way to "insert" data source for cells in MVVM's relationship ? Thanks.

Aucun commentaire:

Enregistrer un commentaire