Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift 2.0 Enumerations and Optionals Introduction to Optionals Initializing Optional Values

shane reichefeld
PLUS
shane reichefeld
Courses Plus Student 2,232 Points

Can someone walk me through this problem step by step so i can better understand?

Help please

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

}

struct Book { let title: String let author: String let price: String? let pubDate: String?

init(){ title = "some string title manual or from another var if you choose" author = "Name of author(same as above)" price = "10.99(This should be a double not a String really, but string can work also.)" pubDate = "5/18/2016(you should do a NSDate here though" } }

So now if you have a UIlabel in your View Controller and you did:

labelName.text = Book.title

the label will now read "some string title manual or from another var if you choose"