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
J V
1,774 PointsCreating 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
Treehouse Guest TeacherSo 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"];
Thomas Deutschländer
3,336 PointsCreate 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
Treehouse Guest TeacherThat looks fine and it should work. Can you try again?
Kire Doki
Courses Plus Student 2,156 PointsIt doesn't work, again.
Amit Bijlani
Treehouse Guest TeacherKire 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.
Emmanuel A. Simon
5,824 PointsEmmanuel A. Simon
5,824 PointsIs 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 €
Emmanuel A. Simon
5,824 PointsEmmanuel A. Simon
5,824 PointsIs 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.
unless the quiz is just refusing me from having refreshed it sooo many times :)
Thanks €
Amit Bijlani
Treehouse Guest TeacherAmit Bijlani
Treehouse Guest TeacherSeems to be working now. Can you check it again?
Emmanuel A. Simon
5,824 PointsEmmanuel A. Simon
5,824 PointsBooya!!!! Phew... hardest Quiz EVER!!!
Worked finally. Thanks Amit. on to the next chapter.
Amit Bijlani
Treehouse Guest TeacherAmit Bijlani
Treehouse Guest TeacherWoohoo!
Mark McCuller
3,539 PointsMark McCuller
3,539 PointsI 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;
}
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
Dastan Aryngazy
Courses Plus Student 1,660 PointsDastan Aryngazy
Courses Plus Student 1,660 PointsAmit, it doesn't work again.
Dastan Aryngazy
Courses Plus Student 1,660 PointsDastan Aryngazy
Courses Plus Student 1,660 PointsAmit, it doesn't work again.
Dastan Aryngazy
Courses Plus Student 1,660 PointsDastan Aryngazy
Courses Plus Student 1,660 PointsAmit, it doesn't work again.