|
Hello, I'm completely new to programming and have never done this before. After doing project 2 of 100 days of SwiftUI, I thought I would try to add some of my own code before moving on to the next project. I managed to add a player name, but the app crashes after question 9 of the game when I play it again & I am not sure why. I see a "Thread 1: fatal error: index out of range" error on line 53: Image(countries[number]). Why does this error occur during a new game? Here is my code:
Thank you |
|
Because when you PS you should use camelCase for properties eg |
|
Thank you @NigelGee! Now when the game restarts, only 9 questions are asked and the final score message is always 9 / 10 for any new games played after the first one. I have tried many combinations to fix this, but I am lost and do not understand why only 9 questions are asked for new games after it restarts. Thank you |
|
|
|
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 more!
Sponsor Hacking with Swift and reach the world's largest Swift community!
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.
Link copied to your pasteboard.