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 Initializing Optional Values

Edward Laurenson
Edward Laurenson
4,278 Points

I have no idea how to do this task... Swift 3 optionals

Im finding swift optionals really hard to understand, can someone please help with this task

optionals.swift
struct Book {
    let title: String
    let author: String
    let price: String?
    let pubDate: String?

    init?(dict: [String : String]){

}

1 Answer

Joel Martin
Joel Martin
2,799 Points

Hey Edward, if you can't figure out how to attack the challenge, your best bet is to rematch the videos.

You can also read some documentation to help you. Like this one for failable initializers : https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html#//apple_ref/doc/uid/TP40014097-CH18-ID224

Once you get some code starting (and if it's still not working), we can help you in a more precise way.