For those on iOS 15, to get the target number to reset AFTER you click the dismiss button titled “Awesome”, your code will look different from Ray’s.
Basically you just put the game.startNewRound(points: game.points(sliderValue:Int(sliderValue)))
inside the curly braces that directly follow Button("Awesome")
I used this and it worked:
.alert("Hello There!", isPresented: $alertIsVisible) {
Button("Awesome") {game.startNewRound(points: game.points(sliderValue:Int(sliderValue)))}
} message: {
let roundedValue = Int(sliderValue.rounded())
Text("The slider's value is \(roundedValue).\n" + "You scored \(game.points(sliderValue: roundedValue)) points this round.")
}
}
1 Like