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 Enum Methods

Matthew Ingram
PLUS
Matthew Ingram
Courses Plus Student 4,718 Points

Enum Methods Challenge Test #2 is broken

Hi there are a bunch of flaws with the challenge test #2 for Enum Methods:) I managed to get the challenge to compile in XCode so I don't think that I am in the wrong here and it compiles without errors is the treehouse workspace. I don't think that the that you mean to ask for "UIBarButtonStyle" that doesn't seem to exist I found another type called UIBarButtonItemStyle so that's what I used. Also the name of the constant done created in the first challenge changes in the next section to doneButton. And now that I believe I have functioning code it still says it isn't working offers no errors or suggestions.

4 Answers

Michael Hulet
Michael Hulet
47,913 Points

You're right that the proper style type name is UIBarButtonItemStyle instead of UIBarButtonStyle, but you can omit the type name when passing a value directly to the UIBarButtonItem initializer. Regardless, I'm gonna report this one to someone who can fix it. As for the rest of your problems, you should be able to find compiler errors (if you have any) by clicking on the "Preview" button and waiting for the results to load. If you post your code here, I might be able to help you debug it

Matthew Ingram
PLUS
Matthew Ingram
Courses Plus Student 4,718 Points

Yes, I am used using the preview button but in this case it didn’t state any errors and the code ran fine in Xcode

Michael Hulet
Michael Hulet
47,913 Points

In that case, if you post your code here, I might be able to help you debug it so it might pass the challenge

Matthew Ingram
PLUS
Matthew Ingram
Courses Plus Student 4,718 Points

enum BarButton { case done(title: String) case edit(title: String) func setButton() -> UIBarButtonItem { switch self { case .done(let title): return UIBarButtonItem(title: title, style: UIBarButtonItemStyle.done, target: nil, action: nil) case .edit(let title): return UIBarButtonItem(title: title, style: UIBarButtonItemStyle.plain, target: nil, action: nil) } } }

let done = BarButton.done(title: "Save")

BarButton.setButton(done)

Matthew Ingram
PLUS
Matthew Ingram
Courses Plus Student 4,718 Points

at the end tho I set the "BarButton.setButton(done)" to whatever they asked for.