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

Variable Defined with the Outlet -- Not Assigned to Anything?

This line of code was generated when I created a IBOutlet for the funFactLabel: @IBOutlet weak var funFactLabel: UILabel!

While I understand that @IBOutlet and weak are new keywords, why does the variable declaration end after the type (why is it not assigned to anything)?

Thanks for your help! John Sanchez

1 Answer

IBOutlet and weak are not new keyboards, they were here in and obj-c. IBOutlet is simply an outlet of a UiElement and weak refers to a method of memory storage.

Think of it as a blank variable, it's better practice to give it a value later rather then set it in stone at the top of your code.