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 2.0 Enumerations and Optionals Introduction to Enumerations Enum Methods

jonlunsford
jonlunsford
15,472 Points

Compiler errors are not showing in Preview.

I'm working on Task 2 of 2 in Swift 2.0 Enumerations and Optionals videos. I'm getting a "Bummer! Your code could not be compiled" message, but when I click Preview, there are no messages showing in red. It is a blank html file. Here is the code I am submitting:

buttons.swift
import Foundation

enum UIBarButtonStyle {
    case Done
    case Plain
    case Bordered
}

class UIBarButtonItem {

    var title: String?
    let style: UIBarButtonStyle
    var target: AnyObject?
    var action: Selector

    init(title: String?, style: UIBarButtonStyle, target: AnyObject?, action: Selector) {
        self.title = title
        self.style = style
        self.target = target
        self.action = action
    }
}
enums.swift
enum Button {
    case Done(String)
    case Edit(String)

    func toUIBarButtonItem() -> UIBarButtonItem {
        switch self {
        case let .Done(doneTitle): return UIBarButtonItem(title: doneTitle, style: UIBarButtonStyle.Done, target: nil, action: nil)
        case let .Edit(editTitle): return UIBarButtonItem(title: editTitle, style: UIBarButtonStyle.Plain, target: nil, action: nil)
        }
    }
}

let doneButton = Button.Done("Done").toUIBarButtonItem()

BTW... This is compiling in XCode just fine.

3 Answers

jonlunsford,

I agree that your code looks ok and is compilable. It's possible that the backend server of teamtreehouse.com was having issues. Maybe refresh refreshing the page and trying again might help.

Florin

jonlunsford
jonlunsford
15,472 Points

Florin:

Thanks for your advice, unfortunately this did not help. I guess I will wait for Support to get in touch with me to figure this one out.

jonlunsford
jonlunsford
15,472 Points

This has been resolved. Thanks.

jonlunsford,

Was this resolved by support? What was the solution?

Florin

jonlunsford
jonlunsford
15,472 Points

Yes it was resolved by Support. The challenge was a two step process and though the first part did not have any direct bearing on the second, by deleting it the compiler would not accept the second part. Rookie mistake!