MVVM and iOS use case

ios swift mvvm

401 观看


68 作者的声誉

Hi I am new to MVVM as well as to iOS programming. I am trying to convert my sample app into MVVM pattern. Here is my simple use case-

I have one view controller class which holds information screen - InfoViewController. I has 4 informative labels with some text. Currently it is implementated in MVC pattern. viewDidLoad method binds iboutlets with text which is static. How can I convert this into MVVM? Here is my understanding

  1. InfoViewController will have InfoViewModel which will be initiliase in viewDidLoad
  2. Struct InfoViewModel will have a.firstLabelText b. secondLabelText and so on..
  3. In viewDidLoad method I will bind iboutlets with viewModel properties which will return text

Currently this text is static but it may come from web service in future so should I create model class here?

Is this correct way for this use case?

作者: Kapil 的来源 发布者: 2017 年 12 月 27 日

回应 (1)


412 作者的声誉

The best way to bind your view and view model is to include a framework that supports you.


I use RxSwift to bind my view model to the view. A nice introduction to mvvvm with rx can be found at

作者: Johannes Starke 发布者: 28.12.2017 11:26