Your First iOS App - Part 34: Challenge: | Ray Wenderlich Videos

Get some more coding practice by implementing the "Start Over" button in Bull's Eye.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5993-your-first-ios-app/lessons/34

Isn’t it unnecessary to call startNewGame() instead of startNewRound() in viewDidLoad() when all it does is reset the values of round and score to zero and then call startNewRound(). The values of round and score are already zero, so this step just adds two lines of unnecessary code. Please let me know if I am missing something!

I think the main point of doing so is to provide ( more ) clarity, as in saying that you start a new game in the beginning makes more sense from an overview standpoint than start new round would while the difference besides that’s pretty minimal :]

Hi everyone!

1:48 I do not understand why do we need in the viewDidLoad() following lines:
let roundedValue = slider.value.rounded()
currentValue = Int(roundedValue)

IMHO we do not need those lines as we override currentValue with 50.

You have a good point. Now that the code resets the currentValue in startNewRound(), those lines are no longer necessary. It would probably best to delete them, as less lines of code is always a good thing!

Hi, Why we don’t use “updateLabels()” in our new func ? I think we need to reset TargetValue with a new game.

@pihtafrazera The startNewGame() method calls the startNewRound() one and the startNewRound() method calls the updateLabels() one.

Please let me know if you have any other questions or issues about the whole thing.

Thank you!