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 Properties Computed Properties

Aananya Vyas
Aananya Vyas
20,157 Points

computed properties

it shows nothing in the preview

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

2 Answers

David Papandrew
David Papandrew
8,386 Points

The challenge is case-sensitive. The given enum names are all lowercase (e.g. "headline", "body", "footnote". Update the enum cases and the switch statement so that those names are lowercase and your code should pass.

Enum names are captialized. Enum members are lowercase: this is just a convention. Aananya code works in Swift and the only reason why his /her code fails is because Treehouse is enforcing the convention in its code review. Overall, if Treehouse provides you with set code (the Text enum in this case), it is not a good idea to change it unless they specifically say to do so. Otherwise you can get errors like these.