Your First iOS and SwiftUI App · Variables and Constants | raywenderlich.com


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

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 = "checkmark.circle.fill" {
        self.score = self.score + 1
        
    } else {
        if image = "circle" {
            self.score = self.score + 0
        }
        
    }
}
return score

}