100 Days of SwiftUI

Day 22

2026-05-10

Project 2, part 3

Finishing the Guess The Flag game, and doing some challenges

Ah ha. Adding the scores is part of the challenges

Quiz: Guess the Flag — 12/12

Challenges

  1. Add an @State property to store the user’s score, modify it when they get an answer right or wrong, then display it in the alert and in the score label.

This seemed… easy? Am I getting better or is it just a simple thing to do. Maybe both.

  1. When someone chooses the wrong flag, tell them their mistake in your alert message – something like “Wrong! That’s the flag of France,” for example.

Also straightforward. I notice that I’m doing most of the challenge work in the flagTapped() function

  1. Make the game show only 8 questions, at which point they see a final alert judging their score and can restart the game.

Ah, this is the real challenge, and I made it harder for myself by reporting the final number of correct answers.

I also can’t seem to get the alerts to work as I want (I want to show the correct/incorrect screen before it shows the final total). But in general it works if not perfectly.

Also, ugly, but 🤷‍♀️