LAST CHANCE: Save 50% on all my Swift books and bundles! >>

SOLVED: Day 22 bug/feature (?) with country names

Forums > 100 Days of SwiftUI

Hello everyone,

I have ben going through the course and faced something in Day 22 I could not understand.

The original code had a line:

@State private var countries = ["Estonia", "France", "Germany", "Ireland", "Italy", "Nigeria", "Poland", "Russia", "Spain", "UK", "US"].shuffled()

I tried to modify it a bit to make the names proper:

@State private var countries = ["Estonia", "France", "Germany", "Ireland", "Italy", "Nigeria", "Poland", "Russia", "Spain", "The UK", "The US"].shuffled()

Basically, changing "US" to "the US" and "UK" to "the UK". When I did that, I noticed that flag of the US and the UK stopped showing up, even though they were still in the game. Even more, the app asked about them: Screenshot 1 Screenshot 2

It works just fine with the original array.

Did I miss anything in the videos? Why does it render the app the way it does?

3      

In Assets Catalog you added files with the names of countries. Right? If you have a file with the name of "US" and trying to get the picture with "The US" which does not exist in your catalog. XCode cannot predict the name of your files without providing correct spelling.

3      

Owww, I did not even think about that! Thank you for the clarification, @ygeras!

3      

Hacking with Swift is sponsored by Essential Developer.

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until July 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.