Ray Wenderlich First iOS SwiftUI App Course - Part 4

Yes! Some momentum - four entries this week is pretty good. Right, straight on to the next part!

Start Time - 09:07

More Swift Basics

A challenge straight away! Showing the score. OK, let's have a go...

I got MOST of this but tried to put in the code inside the function, rather than in the button bit of code. No matter - still getting used to SwiftUI.

Paused at 09:23 (need to sort breakfast!)

Restart at 09:46

Right, so the bug in the code is that the target number gets updated before the calculation, so we want the updating to happen after the alert button is pressed....

So this works! What you need to do is put the code inside the curly braces by the dismiss button. This means that the code actually happens when the button is pressed. This makes sense for updating. I've had this before in games with the round changing before the points have been updated etc.

Challenge - tracking rounds!

OK, so for this I need the state variable. I'm getting used to that - if anything links to an object then it needs the @state! So I got it all! Done!

Ray spots a DRY but it is so minimal I don't see the point of yet another function for that!

Challenge - bonus points!

Needed a little help with the order of this. I tried just adding to the points scored but that didn't work. So I put in the bonus value separately.

Starting over challenge!

Got most of this but didn't update the target and slider value. The point here is to do it in a separate method, then put that method into the button code. That is just good practice to make the code easier to follow. Cool!

Finish Time 10:22 (52 minutes total)

Good session today! Chapter all done and will be onto the last one later today or tomorrow!

Comments

Popular posts from this blog

*Xcode Project Entry 2* F1 Quiz - part 1

Angela Yu Course Part 10 (up to lesson 112)

Angela Yu Xcode 12 Course - Part 7 (lectures 74 to 79)