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 trialKue Yau
1,890 PointsStuck on Quiz:Using a Custom Class
Create an instance of the Song class with the designated initializer initWithSinger:(NSString *)s and singer named "James Brown".
Song *popSong =
I have tried many times but still have no clue. Thanks
3 Answers
Marshall Huss
3,504 PointsIn this case it would be the same as alloc
and init
ing a class except you would use the designated initializer
instead and pass in the NSString
argument`.
// basic init
Song *popSong = [[Song alloc] init];
// designated initializer
Song *popSong = [[Song alloc] initWithSinger:@"James Brown"];
David Collins
6,643 PointsI had this issue as well, it was driving me nuts.
This is what I had. Song *popSong = [[Song alloc]initWithSinger:@"James Brown"];
I kept getting marked as incorrect because there was no space after the first close square bracket.
tiagobandeira
27,862 PointsTry song instead of Song.