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 trial

iOS

HELP w/ Vending Machine app! Everything works fine until I select an item or update quantity.

I got done with the Vending Machine track and it loads up the app just fine, it lets me add funds as expected but as soon as I select and item or hit the update quantity button, it gives me an error as if it has something to do with the quantity stepper. It gives me this error: "fatal error: unexpectedly found nil while unwrapping an Optional value (lldb) "

Then highlights this line code: quantityStepper.value = 1 Which is found underneath the "// MARK: - UICollectionViewDelegate" section

If I click on the update quantity button, it gives me the same error and takes me to this line of code: let quantity = Int(quantityStepper.value) Which is part of the "IBAction func updateQuantity" section.

The update quantity button is connected with this outlet and there are no additional or irrelevant connections.

Please help me out with this and let me know if you want to see a specific piece of code!

1 Answer

It sounds like you are force unwrapping a value, so you probably put a ! where you should have ?.