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

I watched the video, if these aren't examples of associated values then what are?

I watched the video, if these aren't examples of associated values then what are?

enums.swift
enum MobilePhone {
    case iphone(String)
    case android(String)
    case windowsPhone(String)


}

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

when I hit check work, I get an error that says " Make sure your enum members contain associated values"

2 Answers

I found out what was wrong. the error I was getting from treehouse was incorrect. I called the member of the enum iPhone instead of iphone because after the directions tell you to label the member "iPhone", they tell you to make sure that you assign the member "iPhone" an associated value.

Also I don't know how to delete this thread, so ill just leave it here.

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Greg,

Your code is correct, except a typo, which is causing a compiler error. When I copy/paste your code into the challenge I receive "error: enum type 'MobilePhone' has no case 'iPhone'; did you mean 'iphone'". This is where your typo is. In your assignment to the constant, you have an upper-cased "P" when is should be lower-cased.

Fix that and it's all good!

Nice work! :) :dizzy: