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 Enumerations Enums with Associated Values

Make sure your enum members contain associated values???

Contain associated values?

enum MobilePhone { case iPhone(Int) case Android case Blackberry case WindowsPhone }

let iPhone = "6S"

1 Answer

Chase Marchione
Chase Marchione
155,055 Points

Hi kask,

  • Per the instructions, each member should have a String value for its associated value. In your code sample, you have the iPhone member set up to expect an Int: try String instead, and do that for each of the members.

  • You will want to assign "6S" to an instance of MobilePhone, and specifically to the iPhone member of that instance. For the syntax for how to do that:

enum MobilePhone {
  case iPhone(String)
  case Android(String)
  case Blackberry(String)
  case WindowsPhone(String)

let iPhone = MobilePhone.iPhone("6S")

Hope this helps!

I was just adding the let iPhone = mobilePhone.iPhone("6S") in thank you for your help :)