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

Project 2 - Are the flags not supposed to shuffle after an answer?

Forums > 100 Days of Swift

I just finished project 2. When I start the app, I get 3 random flags. When I tap the correct answer, the 3 flags stay the same. The country the user needs to guess changes to be any of the 3 flags, but the 3 flags never change.

Is this the expected behaviour or did I do something wrong?

(PS. I know that if I can call countries.shuffle() in the buttonTapped method in the viewController class to make the flags change but I don't think this was part of the assignment.)

3      

OK, I found out that I made a mistake (probably went through it a bit too fast).

I put the countries.shuffle() method before calling askQuestion() instead of making it part of the askQuestion() method. So countries.shuffle() was only called in viewDidLoad() once.

3      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.