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

Stuck 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

In this case it would be the same as alloc and initing 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
David Collins
6,643 Points

I 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.

Try song instead of Song.