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 Structs and their Methods Review and Final Exam

How to see a value of Enum

I managed to write my own code but I have a question regarding an Xcode. On the right panel there is a Enum value but how can see what that value is. For example: I have a new instance and I want to see a status, how can I see it (lets pretend I didn't write that code and I don't know what statuses are available)

2 Answers

you can use the rawValue attribute.

You can also create a function which displays a String value for the enum you created

 enum Status{
    case Pending
    case Doing
    case Completed

        self = .Pending

    func toString() -> String{
        switch self{
        case .Pending:
            return "Pending"
        case .Doing:
            return "Doing"
        case .Completed:
            return "Completed"
        default :
            return "Not a valid status"
struct Task {
    var description : String
    var status = Status()

    init(description : String){
        self.description = description
var taskOne = Task(description: "Shower")
taskOne.status = Status.Completed