Why does this action method exists?

Hello,

I’ve encountered something interesting in my opinion and would have liked to get some feedback on it.

In “Your First iOS 12 App” course you have the following method :

@IBAction func sliderMoved(slider: UISlider) {
    let roundedValue = slider.value.rounded()
    currentValue = Int(roundedValue)
}

my question is:
Why is this method useful and if it is then how? because from what I can see it only reads the value of the slider and updates the “currentValue” variable? which I think could be done inside the “showAlert” method.

Any feedback would be appreciated

Shay

Hi @shaypaustovsky9,
Your question is quite valid however, the function sliderMoved is the event when the slider is moved by the user. After this other events are triggered. It is safest to set the currentValue here and thereby available for use from here.

Hope that helps,

Jayant

This topic was automatically closed after 166 days. New replies are no longer allowed.