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 Build a Weather App with Swift (Retired) Displaying Our Weather Data The End!

Joe Hernandez
Joe Hernandez
5,699 Points

found nil while unwrapping an Optional value when using current location, but if I enter in coordinates it works perfect

I get an fatal error: found nil while unwrapping an Optional value when using current location, but if I enter in coordinates it works perfectly.

1 Answer

Max Hirsh
Max Hirsh
16,773 Points

The way I dealt with this in my code was to use "if let" unwrapping for the location with default location information available in case the location data was nil. I'm not sure if it's the best app design, since users would get weather info for say Portland, Oregon until the location manager picked up a location, but it definitely got the app to work.