UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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?

2      

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.

2      

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

2      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.