It’s time to flex your problem-solving muscles again. You’ll need to use the 5 step process to figure out how to create a countdown timer using StackOverflow and Apple Documentation.
1. Figure out how to create a 60s countdown timer that prints out the seconds remaining every second.
If successful, you should see something like this in your debug console:
Hint 1: Try Googling these search terms: countdown timer Swift stack overflow and clicking on the first link.
Hint 2: If you get errors, try using Xcode’s auto-fix option. To understand the errors better, try googling what it means.
Hint 3: If one of the solutions from StackOverflow doesn't work, try scrolling down to another.
2. Figure out how to trigger the countdown timer to start when you press any of the egg buttons.
If successful, you should see nothing when you first run the app. But only when you press Soft Egg Button, Medium Egg Button or Hard Egg Button does the seconds get printed in the console.
3. Instead of having 5, 7 and 12 minutes in the dictionary, update the dictionary to use seconds instead.
If successful, when you press on any of the egg buttons, you should see the number of seconds it takes to boil in the debug console. E.g. soft egg button will print 300.
4. Instead of always counting down from 60s, figure out how to make the countdown timer use the correct number of seconds it takes to boil the egg of choice, depending on which egg button was pressed.
If successful, you should get a countdown from 300s when you press the soft egg button but get a countdown from 420 when you press the medium egg button.
⚠️ When testing your app, it might not work as expected if you press one egg button and start the timer then press another. Don’t worry we’ll fix this next. As long as you can run the app and get a different starting time then you’ve succeeded.
(Answer in the next lesson, don’t give up until you’ve really tried!)