Solutions

This section provides hands-on walkthroughs for various challenges you'll find elsewhere in my work.

Swift for Complete Beginners

Solutions for the checkpoint challenges you'll encounter as you're learning.

Checkpoint 1

5:19

1. Checkpoint 1

Checkpoint 1 of Swift for Complete Beginners asks you to create an Xcode playground able to convert any value of Celsius into Fahrenheit, then print the result. Let’s solve that now…

Checkpoint 2

5:25

2. Checkpoint 2

Checkpoint 2 of Swift for Complete Beginners asks you to print the number of items in a string array, then print the number of unique items. Let’s solve that now…

Checkpoint 3

6:46

3. Checkpoint 3

Checkpoint 3 of Swift for Complete Beginners asks you to tackle the classic FizzBuzz problem, printing Fizz, Buzz, FizzBuzz, or a number depending on the input. Let’s solve that now…

Checkpoint 4

7:40

4. Checkpoint 4

Checkpoint 4 of Swift for Complete Beginners asks you to find the integer square root an input number within a certain range, or throw errors if you can’t do it. Let’s solve that now…

Checkpoint 5

7:48

5. Checkpoint 5

Checkpoint 5 of Swift for Complete Beginners asks you to process an array of numbers using filter(), sorted(), and map(). Let’s solve that now…

Checkpoint 6

8:34

6. Checkpoint 6

Checkpoint 6 of Swift for Complete Beginners asks you to create a struct to model a car, adding properties and methods that make sense. Let’s solve that now…

Checkpoint 7

7:31

7. Checkpoint 7

Checkpoint 7 of Swift for Complete Beginners asks you to create a class hierarchy to store various types of animals, including properties, methods, and initializers. Let’s solve that now…

Checkpoint 8

7:05

8. Checkpoint 8

Checkpoint 8 of Swift for Complete Beginners asks you to design a protocol to represent a building, then create two structs conforming to it. Let’s solve that now…

Checkpoint 9

6:31

9. Checkpoint 9

Checkpoint 9 of Swift for Complete Beginners asks you to write a function to pick a number from an optional array, or return a random number if that’s not possible. Let’s solve that now…

100 Days of SwiftUI

Solutions for the challenges and milestones you'll encounter as you're learning.

WeSplit

4:41

1. WeSplit

There are three challenges for WeSplit, including adding section headers and showing a grand total. Let’s solve them now…

Challenge 1: Converter

34:06

2. Challenge 1: Converter

This early challenge day asks you to build a converter app that’s able to move between any two similar units, such as kilometers and miles. Let’s solve it now, then we’ll take it further, and then we’ll take it even further

Guess the Flag

14:59

3. Guess the Flag

This challenge asks you to add some important features to Guess the Flag, including a score tracker and a limited number of questions. Let’s solve those now, and tackle a bonus problem at the end just for fun…

Views and Modifiers

5:43

4. Views and Modifiers

This challenge asks you to go back and adjust both project 1 and project 2 based on what you learned, then try your hand at creating a custom view modifier. Let’s tackle it now…

Rock, Paper, Scissors

16:57

5. Rock, Paper, Scissors

This challenge asks you to build a fun brain game using all the SwiftUI skills you’ve learned so far. Let’s tackle it now…

BetterRest

6:57

6. BetterRest

This challenge asks you to adjust the BetterRest user interface to have sections, a picker, and an always-present bedtime calculation. Let’s tackle it now…

Word Scramble

6:23

7. Word Scramble

This challenge asks you to disallow certain words, let users start a new game whenever they want, and also track player scores. Let’s tackle it now…

Animations

7:42

8. Animations

This challenge asks you to add three different animations to the Guess the Flag game from project 2: spinning, fading, and one of your choosing. Let’s tackle it now…

iExpense

13:28

9. iExpense

This challenge asks you to support the user’s preferred currency symbol, style your expenses somehow, then split the list into two sections. Let’s tackle it now…

Moonshot

16:07

10. Moonshot

This challenge asks you to add some extra text to the mission view, break up at least two SwiftUI views, then, for something harder, allow the user to move between a grid and a list for missions. Let’s tackle it now…

Navigation

11:31

11. Navigation

This challenge asks you to switch both iExpense and Moonshot over to using what you've learned about navigation. Let’s tackle it now…

Habit tracking

25:14

12. Habit tracking

This challenge asks you to create a habit-tracking app, optionally with Codable support and completion count. Let’s tackle it now…

Cupcake Corner

13:00

13. Cupcake Corner

This challenge asks you to upgrade the form validation, add a user-facing error, then make the app remember the user's delivery details using UserDefaults. Let’s tackle it now…

Bookworm

6:07

14. Bookworm

This challenge asks you to make sure all book data is provided, to highlight bad books somehow, and to show a date for when each book was read. Let’s tackle it now…

SwiftData

23:25

15. SwiftData

This challenge asks you to upgrade iExpense to use SwiftData, adding sorting and filtering at the same time. Let’s tackle it now…

Friendface, part 1

13:13

16. Friendface, part 1

This challenge asks you to create an app that downloads and decodes JSON from the internet, then shows it in a list. Let’s tackle it now…

Friendface, part 2

14:45

17. Friendface, part 2

This challenge asks you to upgrade our simple Friendface app to make it store a SwiftData cache, so it works just as well offline as online. Let’s tackle it now…

Instafilter

10:17

18. Instafilter

This challenge asks you to disable options when they don't make sense, add more sliders to control effects, and add three extra filters of your choice. Let’s tackle it now…

Bucket List

13:34

19. Bucket List

This challenge asks you to let users switch map styles, show alerts for authentication errors, and create a view model for EditView. Let’s tackle it now…

Accessibility

11:58

20. Accessibility

This challenge asks you to make decorative decorations, make the rows in iExpense read more smoothly with VoiceOver, then conduct your own review of Moonshot and fix it up. Let’s tackle it now…

Hot Prospects

15:47

21. Hot Prospects

This challenge asks you to add an icon to show which prospects have been contacted, to add an editing screen for contacts, and to enable custom sorting for the data. Let’s tackle it now…

Flashzilla

21:43

22. Flashzilla

This challenge asks you to clear the text fields after adding a card, avoid red flashes when changing your mind about a correct card, and reinsert wrong answers back into the deck. Let’s tackle it now…

Layout and Geometry

5:09

23. Layout and Geometry

This challenge asks you make views fade out, scale down, and change their color, all synchronized with the movement in our ScrollView. Let’s tackle it now…

High Rollers

36:20

24. High Rollers

This challenge asks you build an app that simulates random dice rolls on behalf the user, adding haptic feedback to bring it to life, and permanent storage for later reference. Let’s tackle it now…

SnowSeeker

9:50

25. SnowSeeker

This challenge asks you add a photo credit to resort images, handle loading and saving of favorite resorts, then add sorting options to the main listing. Let’s tackle it now…

Drawing

16:27

26. Drawing

This challenge asks you to add create a custom arrow shape, make it animatable, then create a color cycling rectangle with controls for gradient angle. Let’s tackle it now…

Core Data

12:43

27. Core Data

This challenge asks you to adjust FilteredList in three ways: make it accept a string predicate, make it accept an enum predicate, then make it accept an array of sort descriptors for the managed object it uses. Let’s tackle it now…

SwiftData by Example

Solutions for the challenges presented at the end of the introductory project in SwiftData by Example.

iTour

31:19

1. iTour

In my book SwiftData by Example we build a complete introductory project with SwiftUI and SwiftData. At the end I lay out three challenges to help you build your skills further, and we'll solve them here – then go on to solve five bonus challenges too!