Your First iOS & SwiftUI App: An App from Scratch, Episode 16: Variables | raywenderlich.com

Learn how to detect when the user moves the slider, and how to store the result in a variable.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/28797163-your-first-ios-swiftui-app-an-app-from-scratch/lessons/16

At the very end of this video, the “roundedValue” entered is a var. But I see a warning saying that this var is never changed and should be a let, instead.

Is there a code snippet or video instruction on how to complete topics discussed in this lesson for users targeting iOS 15? The code snippet in lesson 12 shows the state of the project at the end of that episode and what it will look like at the end of this course. If I copy and paste that at lesson 16 I will get errors due to missing material that will not be covered until future videos.

This is the code snippet i used to have slider value be rounded. keep in mind this takes place right after

Text.(“100”)
.bold()
}

            Button(action:{
                print("Hello SwiftUI!")
                self.alertIsVisible = true
            }) {
                Text("Hit me")
            }
            .alert("Hello There!", isPresented: $alertIsVisible) {
                Button("Awesome") {}
            } message: {
                let roundedValue = Int(sliderValue.rounded())
                Text("The slider's value is \(roundedValue).")
              }

Hopefully that helps!