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

Creating a Custom Class - Part 1

I had every part of the quiz right except fill in the blank that I added below.

How would you call a method to set the instance singer of a Song object to the singer James Brown? [song ??? :??? ];

3 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

So the question says the following:

Create an instance of the Song class with the designated initializer initWithSinger:(NSString *)s and singer named "James Brown".

Fill in the blanks: Song *popSong = ___________________ ;

A designated initializer means that you are creating a custom default initializer for a class because the standard way to create an instance would be [[Song alloc] init]; However, in this case we have specified the default initializer to be initWithSinger which would mean when you create an instance it should look like: [[Song alloc] initWithSinger:@"name of singer"];

Is there a spacing glitch or some other thing preventing this from passing? I've tried like 16 different combinations of this line..but still no go.

a) [[Song alloc] initWithSinger: @“James Brown”] b) [[Song alloc]initWithSinger: @“James Brown"] c) [[Song alloc]initWithSinger:@“James Brown"] d) [[Song alloc] initWithSinger:@“James Brown"]

unless the quiz is just refusing me from having refreshed it sooo many times :)

Thanks €

Is there a spacing glitch or some other thing preventing this from passing? I've tried like 16 different combinations of this line..but still no go.

a) [[Song alloc] initWithSinger: @“James Brown”] 
b) [[Song alloc]initWithSinger: @“James Brown"] 
c) [[Song alloc]initWithSinger:@“James Brown"] 
d) [[Song alloc] initWithSinger:@“James Brown"]

unless the quiz is just refusing me from having refreshed it sooo many times :)

Thanks €

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

Seems to be working now. Can you check it again?

Booya!!!! Phew... hardest Quiz EVER!!!

Worked finally. Thanks Amit. on to the next chapter.

I can't get this question right (#1) and another question listed below(#2 ).
(#1) How would you call a method to set the instance singer of a Song object to the singer James Brown? Fill in the Boxes. [song BOXES : BOXES ]; Should not the answer look like below,with song having double [[song? [[Song alloc] initWithSinger: @“James Brown”]; my answer is wrong on the quiz.

(#2) Add a getter method for the singer instance variable: @interface Song : NSObject { NSString *singer;
}

  • (void) setSinger:(NSString *)_singer;
  • ( BOXES ) BOXES ; @end

For the Boxes I put in NSString * _singer so the line of code looks like below -(NSString *) _singer; this answer is wrong on the quiz also.

Please help me, thank you.

Mark

Amit, it doesn't work again.

Amit, it doesn't work again.

Amit, it doesn't work again.

Create an instance of the Song class with the designated initializer initWithSinger:(NSString *)s and singer named "James Brown". Answer: Song *popSong = [[Song alloc] initWithSinger: @"James Brown"] ;

For me it's lock right. But it say that it's wrong! Can you help me?

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

That looks fine and it should work. Can you try again?

It doesn't work, again.

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

Kire Doki which question are you referring to? This thread is really old and refers to quite a few questions. Please start a new thread if different from the original.