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

Error. Can't figure it out.

Hello,

I need some help.

The app crashes, as there's an InvalidKey. However, I can't seem to figure out how to fix it!

Here's a link to what it looks like: (https://postimg.org/image/5dehf3dsx/)

1 Answer

The first thing you can do is catching the different error individually.

Ho, I see that you look at your console to get the info about the invalid key.

Anyway, this is good practice to implement the individual error with a catch. like:

catch InventoryError.InvalidKey { }

In your case, just listen to your code ;) Your code says to you that there is an invalidKey. The problem comes either from your enum VendingSelection or from your VendingInventory.plist

You should look for a typo.

It was a typo indeed.

Thank you!