SwiftUI MVVM with Networking

It can’t be that hard!

Steven Curtis
4 min readJan 25, 2023
Photo by Maxwell Nelson on Unsplash

Difficulty: Beginner | Easy | Normal | Challenging

This article has been developed using Xcode 12.1, and Swift 5.3

If you want to develop any sort of `SwiftUI` application you

Prerequisites:

Terminology

SwiftUI: A simple way to build user interfaces Across Apple platforms

The motivation

You will need to create nicely featured Apps. They are going to (probably) make network calls. This means that you need to develop an architecture that is going to support this in your development.

Let’s go MVVM!

The basic architecture

The Main view (which I’ve creatively called ContentView) is instantiated with a view model which is creatively called ContentViewModel.

Therefore in the SceneDelegate contentView is created with let contentView = ContentView(viewModel: ContentViewModel()).

My ContentView isn’t going to do anything in this case, apart from creating a reference to the view model

--

--