Create a SwiftUI Tip Calculator

It’s nice to be nice

Steven Curtis
2 min readMay 10, 2021
Photo by Sam Dan Truong on Unsplash

Difficulty: Beginner | Easy | Normal | Challenging

This article has been developed using Xcode 12.5, and Swift 5.4

The supporting video for this article is available at: https://youtu.be/hkv9eoHxE2Y

Prerequisites:

The opportunity

Yes, yes. After Hello, World many many people create a tip calculator. SwiftUI is no different, and there are plenty of good reasons why we might make a nice little tip calculator. At least this particular article uses the current API (see tips below). SwiftUI seems to be built with MVVM and mind, and so it makes sense that this rather small project is based on that paradigm.

The SwiftUI Tips

Refresh the preview window by using ⌘-⌥-P (command-Option-P)

Be mindful when you are looking for tutorials on the Internet — ObjectBinding and Bindable object (for example) have been deprecated since iOS13 (so they are not covered here).

Creating the Project

We can create a new SwiftUI project, and here we are using the SwiftUI template to do so:

--

--

Responses (1)