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
Tony Warner
1,631 PointsHow to find where the "fatal error: unexpectedly found nil while unwrapping an Optional value" error actually is??!!
Hi,
Here's the issue, I have been working on an app (mostly by following tutorials), and it worked before updating to Swift 3, and I followed along with the Swift 3 update, so everything should be fine, but I'm getting the error: fatal error: unexpectedly found nil while unwrapping an Optional value---here's the problem with this damn error, IT DOESN'T POINT TO A LINE! So I've been combing through the code, and like I said, it DID work before. I can't spot the possible errors very well in Swift 3 either, because I'm not used to the syntax. Is there ANY way to figure this out? Any way to find out where the error is occurring? Are there steps like, "first, check your variables, then check your functions" etc? Please help. I know this is maybe the most common error, and thus, will be very helpful for all students facing an issue like this.
Thanks.
1 Answer
Michael Hulet
47,913 PointsWhat you need to do is set an Exception Breakpoint. This is a special kind of breakpoint that will stop your app as soon as an exception occurs, on that line. You can do this by opening the left pane of Xcode (where all the files usually are), click on the 2nd icon from the left of the top row of that pane (looks like a fat arrow pointing right), then press the + button at the bottom left of that pane, and finally select "Exception Breakpoint". After you do that, you can run your app, and it should stop on the line it crashes