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 an Interactive Story App with Swift 2 Creating the User Interface Programmatically Making a Choice

Boris Likhobabin
Boris Likhobabin
3,581 Points

But what if the second choice is nil don't we the have an empty button?

If so isn't it wrong? Shouldn't we be creating buttons conditionally o whether there is a choice? I mean make second choice button optional itself?

Tomas Salas
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tomas Salas
Front End Web Development Techdegree Graduate 37,934 Points

Hello Boris!, optionals, in some cases, are use to throw a value that is different to nil. Created by an if statement " if something == nil {code}", all of this is Swift security protocols you must follow to avoid crushes ... Swift is not really friendly unwrapping nil values so be careful !!, hope this can help you ^.^

Another think you should check out is "!" at the end of a type, for example: @IBOutlet weak var window: NSWindow!

that "!" is telling swift not to access the value will it is nil. Awesome stuff.