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 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"