Your First iOS & SwiftUI App: An App from Scratch
Part 1: SwiftUI Data SwiftUI State
— iOS & Swift

Lesson Complete

Play Next Lesson
Next

SwiftUI State

.alert(
  "Hello there!",
  isPresented: $alertIsVisible,
  presenting: {
    let roundedValue = Int(sliderValue.rounded())
    return (
      roundedValue,
      game.points(sliderValue: roundedValue)
    )
  } () as (roundedValue: Int, points: Int)
) { data in
  Button("Awesome!") {
    game.startNewRound(points: data.points)
  }
} message: { data in
  Text("The slider's value is \(data.roundedValue).\n" + "You scored \(data.points) points this round.")
}

Learn about an important concept called SwiftUI state, which helps you keep your user interface and app state always consistent.

Contributors

Reviews

Comments