Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDaniel Yoo
3,812 Pointssender.value (UIStepper) does not reset
The reset() function sets the quantity back to 1, but when you select a different item and start adding/subtracting quantity, it does not start from 1. The quantity value jumps from the quantity value that was left off from previously selected item.
3 Answers
Martin Wildfeuer
Courses Plus Student 11,071 PointsHey there, just had a look at the official download.
This seems to be a bug indeed. In order to also reset the stepper, you could create an outlet for your stepper. That is, the stepper itself, not the action. Just as with the other elements before, CTRL - click the stepper in storyboard and connect it to your view controller.
@IBOutlet weak var stepper: UIStepper!
This way, you can access the stepper and its' value directly. Then, in the reset()
function, you could also reset the stepper value. Before, only the label was updated, but not the stepper value, just as you said.
func reset() {
quantity = 1
stepper.value = 1 // Reset the stepper
updateTotalPriceLabel()
updateQuantityLabel()
}
Hope that makes sense :)
Pasan Premaratne, I did not follow that course, maybe this is worth mentioning. If it's up to the students to fix the little things, than probably not ;)
Pasan Premaratne
Treehouse TeacherWill post a fix to this on Monday! Thanks for the heads up everyone and apologies for the error.
James Estrada
Full Stack JavaScript Techdegree Student 25,866 PointsI still don't see any fix in the project downloads. Is it posted somewhere else?
David Keck
5,723 PointsSame problem, even in official download, FYI.
Martin Wildfeuer
Courses Plus Student 11,071 PointsSry, but I deleted our comments, as this was not a problem with your code but with the course. It's easier to follow this way.
Daniel Yoo
3,812 PointsDaniel Yoo
3,812 PointsAwesome. Thanks Martin!
JIN ZHANG
2,542 PointsJIN ZHANG
2,542 PointsThat works!!!
Thank you!