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

Brian Law
Brian Law
4,099 Points

I'm having trouble with Enum Methods

The challenge states that there's a compiler error, but the compiler doesn't return any errors. Furthermore, the code works in Xcode. It seems like something I'm doing doesn't line up with what the challenge wants, but I'm not sure what and I'm not sure why it thinks it's a compiler issue. Any help would be appreciated. Thanks!

2 Answers

Aniruddha Shukla
Aniruddha Shukla
2,846 Points

Looked at your posted image. Code looks correct. This is dumb but try changing the method signature to just how they want it in the challenge.

func button() -> UIBarButtonItem

Brian Law
Brian Law
4,099 Points

Thanks! That was it. For anyone else having issues with this problem, I'll also point out that the error message and the problem were inconsistent with what they wanted the name of the constant to be. The error calls for doneButton and the challenge calls for button and button is the one that works

Pavel Fomchenkov
Pavel Fomchenkov
20,897 Points

Can confirm. I got two different error messages telling me that the final constant should be named either done or doneButton, but the real answer is that it should be called the neither of both. Call it just button.

Also after you implement the func button() -> UIBarButtonItem correctly, you will need these lines to make the parser happy:

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