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 Enumerations and Optionals in Swift Introduction to Enumerations Associated Enums

Where am I going wrong with the code for the next code challenge? Seems simple, but for some reason I can't pass it.

I was feeling pretty confident going into this challenge, but for some reason my code is not being accepted by the challenge (task instructions below). When I open the "Preview", it does not show any kind of errors, or even anything else... Just blank. I have tried searching for other solutions to my problem, but all I am coming up with are codes basically the same as mine. Where am I going wrong, or what am I not seeing?

Task Instructions

For this task, let's create a enum named MobilePhone. The enum will have three members: iphone, android and windowsPhone.

Each of these members should have a String value as its associated value.

Once you have an enum declared, assign the value of the iPhone member with an associated value of "7 Plus" to a constant named iphone.

My Code

enum MobilePhone {
  case iPhone(String)
  case android(String)
  case windowsPhone(String)
}

let iphone = MobilePhone.iPhone("7 Plus")

1 Answer

Nathan F.
Nathan F.
30,773 Points

This is going to sound silly, especially because of the official naming conventions for the phone, but the challenge specifies the members should be iphone, android, and windowsPhone. Try renaming the iPhone case to iphone and see whether the challenge accepts it.

it worked!

Jerome Heaven
Jerome Heaven
8,641 Points

One year later and you're still a genius! Thanks man!