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

Darcy Phillips
Darcy Phillips
4,087 Points

confused by code challenge question- Intermediate Swift 2

I am having trouble with this first code challenge question, I can't seem to get my bearings with it.

  1. Is the computed property supposed to be created in the level tracker struct I created in the previous question? Otherwise i don't understand what struct the computed property is supposed to be created in.
  2. The dot notation given, "Text.Headline.style" is used in the all the preceding videos when referencing a struct. So my expectation here would then be that there would somehow have to be a struct called "Text" with a property called "Headline" etc. I don't understand how to create a computed property as part of a struct that is referenced by an enum.case notation.

I am struggling to even know what my question is, so anything to help me get on track is appreciated. thanks! darcy

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

enum Text {
  case Headline
  case Body
  case Footnote
}
Darcy Phillips
Darcy Phillips
4,087 Points

Ok, I think I've answered my own question. I see by more careful reading of the docs that enums can in fact contain computed properties. That was the piece I was missing.

Thanks anyway everyone.