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 Intermediate Swift 2 Properties Computed Properties

Jack Hancock
Jack Hancock
3,613 Points

I have rewatched the videos in this course but I still have no clue how to do this task. I don't even know what Q to ask

I know this is not a question but I really don't know what I should do. I guess I don't know how to use the enum in a way that I can call up the style computed property. I wish there was some resources that I could be given on the task so that I wouldn't have to ask a question of this nature. Not sure how to even start.

enum.swift
let UIFontTextStyleHeadline = "UIFontTextStyleHeadline"
let UIFontTextStyleBody = "UIFontTextStyleBody"
let UIFontTextStyleFootnote = "UIFontTextStyleFootnote"

enum Text {
  case Headline
  case Body
  case Footnote

    var style: String{

    }
}

2 Answers

You have made a good start. Here is a hint, try incorporating a switch statement into your style's computed property.

jon kelson
jon kelson
5,149 Points

computed properties . keep the “var style” switch statement in the curly braces body of the ” enum text” so you can call it like this “Text.Headline.style”

let UIFontTextStyleHeadline = "UIFontTextStyleHeadline" let UIFontTextStyleBody = "UIFontTextStyleBody" let UIFontTextStyleFootnote = "UIFontTextStyleFootnote"

enum Text { case Headline case Body case Footnote

var style: String{
    switch self {
    case .Headline: return "UIFontTextStyleHeadline"
    case .Body: return "UIFontTextStyleBody"
    case .Footnote: return "UIFontTextStyleFootnote"
    }



}

}

Text.Headline.style