I\'m stuck on a design decision with creating view-models for table view\'s cells. Data for each cell is provided by a data source class (has an array of Contacts
)
Unless you have a specific problem that's solved with Model-View-ViewModel
then attempting to adopt it just for 'best practices' is going to end up introducing a lot of unnecessary complexity.
Your data-source is what's responsible for populating your table. Nothing other than your datasource needs a reference to contacts
as it will update your table with this data.
View Models
only come into play when you need to do complex UI interactions and updates. The VM is responsible for encapsulating the state of your view, things like...
When changes are made to your View, your View Model
is responsible for making updates to your Model
(when necessary) in order to reflect the changes that have been made to that Model
through the UI.
With all that said, View Models don't make sense in IOS that's because IOS makes use of View Controllers
in the design methodology called MVC
(Model-View-Controller)