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 trialShaine Greenwood
4,022 PointsException raised hen returning iconImage
Hi
The last part of the video has us 'return iconImage' in the weatherIconFromString function, but not as an unwrapped optional. Xcode complains about this not being unwrapped as we've made 'icon' an optional, so I add the "!" or bang at the end and Xcode is fine.
When I go to run the app, however, it just crashes after loading and provides me with a "EXC_BAD_INSTRUCTION" fatal error as it finds 'nil'.
I'm not finding a solution to this problem. Any ideas?
Shaine Greenwood
4,022 PointsHi Kyle,
Thanks for your reply; I figured it out! I'd forgotten to ad the "if (error == nil) {}" piece, so the app wasn't loading the dictionary of JSON data. Whoops!
Thanks again, Shaine
Kyle Pontius
6,190 PointsNice work, best of luck!
Kyle
Kyle Pontius
6,190 PointsKyle Pontius
6,190 PointsShaine,
Can you post the all code you used for the method? That may help us get pointed in the right direction.
In the mean time, you can use breakpoints to step through and see where it fails. That should give you a clue to where the problem is occuring. Here is a simple, and seemingly straightforward tutorial on how to use breakpoints if you are unfamiliar:
Breakpoints Tutorial
It's an essential art in programming, definitely worth a few minutes if you aren't familiar with it yet.
Good luck, Kyle