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