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.

Development Tools

Code challenge in Object Oriented programming Swift 2.0 - Initializer

I’m trying to solve one of the challenges in the Object Oriented Swift 2.0 course. I’ve completed the course except for this one challenge which seems to be stuck due to an error or I simply don’t get how to correctly add my code. Basically, whatever I do, when I check the work, the message is “Bummer! Don’t use the memberwise initializer Swift creates. Add your own custom initialiser as specified in the directions”.

I would like to believe that my code is correct and the message is wrong but sadly these challenges don’t offer a solution to look at which makes it a bit cumbersome if students struggle with the actual problem.

In this particular case, if I preview my code, I see no errors and everything also works if I do this in the playground on my Mac. So I’m wondering whether there’s something wrong. No matter what I try, the answer is always the same.

Screenshot including my code and error message: https://d33v4339jhl8k0.cloudfront.net/inline/490/342393b7afaec82b0461c116ce0ad61e6101a28b/106d17456b5cc2e6ace019a5697009c49c05fff3/PastedGraphic-18.png

Link to Challenge: https://teamtreehouse.com/library/objectoriented-swift-20/complex-data-structures/custom-initializers

Any hints would be greatly appreciated.

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Here's a hint. The init already has all the info it needs to make the description. So you don't have to pass in a description.

edited for another hint

Also the challenge sort of hints at this in this line: "Note: Init methods typically list parameters in the same order of property declaration. For this task, stick to the order red,green,blue,alpha." Notice how it leaves out description...

Thanks, Jennifer for you super quick reply. Needless to say that it worked after I removed the description just as you said. I truly appreciate your hint! Not only did it solve the problem but it also untangled one of the main confusions I had in my brain with inits during this course. You sure made my day!