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 Enumerations and Optionals in Swift Introduction to Optionals Nil Values in Collections

Your job is to assign the string containing the value for the lead actor (which for the sake of the example is at

I need a little bit of help

let movieDictionary = ["Spectre": ["cast": ["Daniel Craig", "Christoph Waltz", "LÊa Seydoux", "Ralph Fiennes", "Monica Bellucci", "Naomie Harris"]]]

var leadActor: String = ""

// Enter code below

if let movieTitle = movieDictionary["Spectre"], let leadActor = movieTitle["cast"] {

1 Answer

if let movieTitle = movieDictionary["Spectre"], let cast = movieTitle["cast"] {
  leadActor = cast[0]

You've grasped the concepts of optionals and syntax just be careful whilst reading the challenge question, we've all done it :). Remember that it asks you to place the lead actor into the leadActor variable not print it to the console, so as my example above shows you just assign it to the variable and you can print it if you wish.

Hope that helps.