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 Simple iPhone App with Swift Views and View Controllers IBOutlet

Samar Khanna
Samar Khanna
1,757 Points

Why do we need to unwrap that UILabel?

Why do we have to unwrap UILabel when we haven't even defined it as an optional. What is this unwrap thing thats going on here? i don't get it.

I mean understand optionals, but not over here. Pls help

1 Answer

Erik Lopez
Erik Lopez
6,082 Points

UILabel is already an Optional, because of the fact that when the code executes, it may or may not find a UILabel in the interface, since Optionals can be nil. Xcode simply force unwraps the UILabel for you when assigning the property "funFactLabel" so that you don't have to unwrap it every time you want to access the label in code.