Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

iOS Techdegree Project 2 Stuck

My project seems to run fine once I debug one issue. Can someone look at my code, run my app, and see what's wrong. Thank you and I really appreciate it.

https://github.com/Bill-Merickel/EnhancedQuizApp

Taylor Amsler
Taylor Amsler
4,427 Points

Hey Bill. Pretty new to this too, but could you describe your issue in more detail? I noticed a couple when I looked:

1) You employ a delay between each question, but you don't disable buttons after a question is answered. This allows a user to select multiple answers (even after they know whether they were correct or not) and your code is not built to handle this so the app crashes.

You could account for that possibility, hide the buttons or disable the buttons from selection (perhaps while highlighting the correct answer). Not sure the best way to go about that, but my first instinct is that observer properties could help.

2) Pretty sure your playAgain button is not hooked up correctly.

3) Related to playAgain: I may be wrong on this, but it seems to me that your questions inventory doesn't allow for questions to be re-used. This means that whenever you attempt to restart the game, the inventory runs out of questions, causing a fatal error as it attempts to call the next question where a next question doesn't exist.

Once again, pretty new to coding, but I hope this was helpful. Good luck.

Thank you for looking into it Taylor. Here's a more detailed description. When I run the game in the simulator, the noise plays and the question and answers are displayed. When I click on a answer, the game crashes. I go to the debug area, and this line of code is highlighted in green. let selectedQuestionDict = trivia[indexOfSelectedQuestion] When I say continue the program over this issue, it functions well until the next question comes up. This repeats until all questions are done. I'll look into your issues and see what works. Again, thank you Taylor.

Quick update Taylor, I took your advice on the buttons, and it works. The only thing that doesn't is play again, which I'll check now.

Thank you Taylor. I looked at your suggestions, applied them, and my code runs well. Thank you for all your help!

1 Answer

Taylor Amsler
Taylor Amsler
4,427 Points

Glad I could help! I'm learning here too, so this was helpful for me as well.

Cheers.