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 trialStijn van Lieshout
3,646 PointsWhy call updateTotalPriceLabel() inside reset method?
I'm wondering why you'd call the updateTotalPriceLabel method inside the reset function? When selecting a new item, total price will also update without it, so why bother?
func reset() {
quantity = 1
updateQuantityLabel()
updateTotalPriceLabel()
}
1 Answer
David Lin
35,864 PointsYou are right, though updateTotalPriceLabel seems to belong in the reset() method, in case it is used elsewhere. Perhaps the best thing to do is remove the extra updateTotalPriceLabel() call in the collectionView.didSelectItemAtIndexPath method, since it is redundant if reset() is also called.