Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Build a Weather App with Swift (Retired) Displaying Our Weather Data The End!

Ryan Jin
Ryan Jin
15,337 Points

Downloaded project doesn't work

After I download the project, it shows that there are some places that needs to unwrap an optional. And I won't let me run if I don't force unwrap it. So I did force unwrap it, and after that, the app crashes, saying that it found nil while unwrapping an optional. I changed it back, and there is an error. Can somebody give me the right program.

1 Answer

Mohsen Lotfi
Mohsen Lotfi
2,694 Points

Can you provide your code so we can better understand the situation.

Basically you need to unwrap an optional before using it, however the whole concept of optional is that the value can be nil. in such cases you can check the value to see if its nil before force unwrapping like following

if xyz != nil {
   //Do Something
}

Again without the code it is hard to understand the problem.