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 Swift Enums and Structs Enums and their Methods Methods or Member Functions

Error about return enum.case.rawValue

In the beginning of the video Mr. Amit's code has no error in the function daysTillWeekend. In my code it says "Day does not have a member named 'rawValue'. Will someone help me?

2 Answers

Chris Shaw
Chris Shaw
26,650 Points

Hi arnavthecoder,

In order for an enum to register the property rawValue you need to assign an explicit type to it which matches the initial case value, for example.

enum Days: Int {
    case Monday = 1, Tuesday, Wednesday, Thursday, Friday,
        Saturday, Sunday


In the above example I've assigned the type Int which initialises the rawValue property and sets a requirement that the first case statement must have a value, because I've used an Int type all I need to do is set the first case statement to 1 and Swift will do the rest, for strings we need to define each value.

Hope that helps.

Mayank Chopra
Mayank Chopra
2,608 Points

I had the same problem, looks like .rawValue has been changed to .toRaw() by Swift