Member-only story

MVVM iOS

Mr.Javed Multani
4 min readOct 3, 2020

--

MVVM Without Reactive Programming

I’ll start with a really short explanation what is and why use Model-View-ViewModel (MVVM) design pattern in your iOS apps. When iOS first appeared, Apple suggested to use MVC (Model-View-Controller) as a design pattern. They showed it in all of their examples and all first developers were happy using it because it nicely separated concerns between business logic and user interface. As applications became larger and more complex a new problem appeared appropriately called Massive View Controllers (MVC). Because all business logic was added in the ViewController, with time they usually became too large and complex. To avoid MVC issue, a new design pattern was introduced to the world of iOS — Model-View-ViewModel (MVVM) pattern.

The diagram above shows how MVVM looks like. You have a standard ViewController + View (in storyboard, XIB or Code), which acts as MVVM’s View (in later text — View will reference MVVM’s View). A view has a reference to a ViewModel, where our business logic is. It’s important to notice that ViewModel doesn’t know anything about the View and never has a reference to the view. ViewModel has a reference to a Model.This is enough with a theoretical part of the MVVM.

One of the main issues with MVVM is how to update View via the ViewModel when ViewModel doesn’t have any

references and doesn’t even know anything about the View.

The main part of this example is to show how to use MVVM (more precisely, how to bind ViewModel and View) without…

--

--

Mr.Javed Multani
Mr.Javed Multani

Written by Mr.Javed Multani

Software Engineer | Certified ScrumMaster® (CSM) | UX Researcher | Youtuber | Tech Writer

No responses yet