Your First iOS and SwiftUI App · Variables and Constants |

This is a companion discussion topic for the original entry at

We use the variable (now constant by the end of the video) “roundedValue” twice in the code to calculate the same value. Would it make sense to reference it in the pointsForCurrentRound() Function?

Hi there! I’d like to make a function to add a score and update the text that shows the score according to a button image state. Here is my thinking:

func totalRoundScore() -> Int {
let score: Int
let image = String

    if image = "" {
        self.score = self.score + 1
    } else {
        if image = "circle" {
            self.score = self.score + 0
return score