import UIKit
class ViewController: UIViewController {
var currentValue: Int = 0
var targetValue = 0
@IBOutlet var slider: UISlider!
@IBOutlet var targetLabel UILabel!
override func viewDidLoad() {
super.viewDidLoad()
startNewRound() // Replace previous code with this
currentValue = lroundf(slider.value)
targetValue = Int.random(in: 1...100)
}
@IBAction func sliderMoved(_ slider: UISlider)
{
print("The value of the slider is now: \(slider.value)")
}
@IBAction func showAlert() {
let message = "The value of the slider is: \(currentValue)" + "\nThe target value is: \(targetValue)"
let alert = UIAlertController (title: "Hello, World", message: message, preferredStyle: .alert) // changed
let action = UIAlertAction(title: "OK", // changed
style: .default,
handler: nil)
alert.addAction(action)
present(alert, animated: true, completion: nil)
targetValue = Int.random(in: 1...100)
currentValue = 50
slider.value = Float(currentValue )
startNewRound()
}
/*@IBAction func sliderMoved(_ slider: UISlider) {
currentValue = lroundf(slider.value)
}*/
func startNewRound() {
targetValue = Int.random(in: 1...100)
currentValue = 50
slider.value = Float(currentValue)
}
}
Consecutive declarations on a line must be separated by ‘:’. Is one of the error messages I’m receiving
. Please help.