A beginner’s guide to @State, @StateObject and @ObservedObject in SwiftUI

This article is an attempt to help beginners, like myself, to understand fundamental things about SwiftUI. This is the type of article I wish existed when I was just starting. Hope it’ll save you some time and struggle.

Feel free to leave a comment with corrections or general feedback.


In order to really understand state management in SwiftUI, and in order to follow along with this article, you need to know a couple of things:

  • Difference between value type and reference type

If you don’t feel confident enough about those topics…

Let’s start with tools. Takes only a couple of minutes to set them up and soon it will be painful to use Git without them.

Micro as Default Editor

Unless you’re using Vim as your main IDE, you need something that resembles your GUI editor but on the command line, with standard navigation, mouse support, and syntax highlighting. Micro is exactly that.

Install and set it as your Git editor:

git config --global core.editor micro

diff-so-fancy Instead of Default Diff

Standard diff is fine, but with minimal effort, it can be even better. Take a look: left — standard, right — diff-so-fancy.

This may seem a bit controversial, but I want to encourage you to fit less information on a screen. As we are, developers, often tend to do right the opposite.

I’m talking about font size in your IDE or text editor, whatever you prefer.

12, 13, 14 pixels are too small

Developers around me mostly use font sizes from 12 to 14 pixels.

Those are very small fonts for a people who stare at letters most of the day. Even for ones with perfect sight, which is a rare case in our profession, I would really suggest increasing font sizes.

You’re making pretty big effort processing those…

Follow me on Twitter. I share tips and resources that had a meaningful impact.

Frontend development

Core toolkit which helps me be productive and creative.

My laptop is MacBook Pro (Retina, 15-inch, Mid 2015) with 2,5 GHz Intel Core i7 and 16GB of RAM.


I switched from Sublime Text and completely happy with WebStorm’s performance. Not to mention that the set of features is way better.

Refactoring feature saves me a lot of time every single day. Autocompletion is great, especially with statically-typed languages.

One of my must-have plugins is IdeaVim. I’m not a power vim-user but navigation and window-management with vim-shortcuts…

Mykola Harmash

Software engineer mostly focused on full-stack web development and apps for Apple platforms. https://twitter.com/mykola_harmash

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store