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 Enums and Structs Enums Enum Members and Raw Values

Magnus Larsen
PLUS
Magnus Larsen
Courses Plus Student 2,025 Points

"'Day.Type' does not have a member named .rawValue"

I get an error message saying "'Day.Type' does not have a member named .rawValue" What am I doing wrong? I understand the error message but I do not know how I can fix it as my code is exactly the same as Amit's.

enum Day: Int {
    case monday = 1, tuesday = 2, wednesday = 3, thursday = 4, friday = 5, saturday = 6 , sunday = 7

}

func daysTillWeekend(day: Day) -> Int {
    return Day.saturday.rawValue - Day.rawValue
}

1 Answer

Daniel Sattler
Daniel Sattler
4,867 Points

In your daysTillWeekend() Function your second day need to be lowercase ;-)

so change

func daysTillWeekend(day: Day) -> Int {

    return Day.saturday.rawValue - Day.rawValue

}

to

func daysTillWeekend(day: Day) -> Int {

    return Day.saturday.rawValue - day.rawValue

}