Your First iOS and UIKit App · Writing Methods | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5993-your-first-ios-and-uikit-app/lessons/17

Hi,

I have a problem in the Writing Methods video in about 4:05. Why currentValue should convert to Float? I thought currentValue has already declared the type as Int?

Thanks for answering my question in advanced.
Doma
26%20PM

The currentValue variable is type Int, because that is how the game is designed. The slider.value, on the other hand, is type Float.

So, you have to convert slider.value to Int when assigning it to currentValue, and you have to convert currentValue to Float when assigning it to slider.value.

1 Like

Thanks for reply. Really helpful.