Part 4: Slider and Labels

Welcome, this is a thread for collaboration, questions, and feedback on Part 4 of the iOS Apprentice Email course.

“Your First Bug” Challenge Solution

The problem is that if you don’t move the slider, the sliderMoved() message is never sent and you never put the slider’s value into the currentValue variable.

The default value for the currentValue variable is 0, and that is what you are seeing here.

➤ To fix this bug, change the declaration of currentValue to:

var currentValue: Int = 50

Now the starting value of currentValue is 50, which should be the same value as the slider’s initial position.

➤ Run the app again and verify that the bug is fixed.

Note that there is also another (better) way to fix this problem, that you will learn about in the next part of this course. :]


Here’s a download for the project to use at the beginning of this email: (26.8 KB)

Here’s a download for the project where it stands at the end of this email: (27.6 KB)

Hi, there.
I am sure to had followed the steps for the sliderMoved: action to hooked up to the slider’s Value Changed event. But when I moved the slider either to left or right side not value or text message is written to the Console - the right-hand pane in the Debug area. Has it been found any issues on this step?


@rray Do you still have issues with this?

Xcode 12 does not appear to set the slider value to the initial value set in the Attributes inspector. It seems to default to 1 regardless of what is put into the Value area in Xcode. I downloaded your sample code to make sure it wasn’t something I was doing, so unless there is an Xcode setting that I have to update to make that work then either Apple changed the behavior or it is broken.