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! While you're at it, check out some resources Treehouse students have shared here.
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 trialBill Merickel
11,420 PointsiOS Techdegree Project 2 help!!
Hello all. I am on the second project for the iOS techdegree and I am confused. XCode is telling me I have errors and they don't even make sense. My project is in the link below (GitHub). Would someone be so kind as to review my project so far and tell me what I may have wrong? Thank you very much.
3 Answers
Tosin Peters
9,541 Pointsin your viewController.swift file, the check answer IBAction, you are missing a ')' at the end of the if statement
if (sender === button1 && correctAnswer == true) || (sender === button2 && correctAnswer == true) || (sender === button1 && correctAnswer == true) || (sender === button2 && correctAnswer == true)
For the error Variable 'correctAnswer' captured by a closure before being initialized
you have to initialize the correct answer variable, maybe to something like var correctAnswer = false
Tosin Peters
9,541 PointsYou could use the button1.setTitle("", forState: ) to display text on your buttons
https://teamtreehouse.com/community/changing-the-text-of-a-button-in-swift
Bill Merickel
11,420 PointsThank you very much Tosin!
Bill Merickel
11,420 PointsBill Merickel
11,420 PointsAahh! Thank you. And just one more question, how do I change the text inside the button so when the game starts, it displays the answers?