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


How to give the user time to respond in ios

I am currently building an app that prompts users questions.How can I give the user time to respond before the computer checks if the answer is correct.

2 Answers

Allen Soberano
Allen Soberano
13,634 Points

One possible idea:

questionArray answerArray i = 0 func questionToDisplay() - displays question from collection (array, dict, etc)

func checkAnswer() - checks if user is correct from answerArray[i]

Step 1: display question1 from array: questionToDisplay()

Step 2: when user clicks button answer or submit button it runs checkAnswer(): which checks if answer is correct, increments i += 1 and now does questionToDisplay() again but it's now the next question.

I realize you might want to see actual code but hopefully this will give you a simplified overview on a way to do it.

thank you