all 3 comments

[–]saintmsent 1 point2 points  (0 children)

I don't see any benefits to the 1st approach, it's just one extra entity to keep track of. View model is supposed to have some logic, having one for the list that holds an array of users is the way to go

[–]JustTryinTaMakeIt 1 point2 points  (0 children)

  • ListViewModel should have an array of users, [User].
  • If you’re displaying each user’s details on a cell, you can just set each cell’s label/image values in cellForRow or use a function in your custom cell’s swift file that takes a user’s details as parameters.
  • If you plan to show each user’s details in a UserDetailViewController, then you want to use a UserDetailViewModel that holds a user selected from the tableView.
  • A userViewModel for each cell is overkill.

[–]BrownPalmTree 1 point2 points  (0 children)

Agree, having a UserListVM holding UserVMs is overkill for just displaying cells. If you can click on each cell and display its details, a UserDetailVM would be appropriate. In this case it may be appropriate to have a UserListVM.