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

Help with Designated Initializers and Convenience... Quiz

The question just asks: "Fill in the blank below:"

  • ( ? ) initWithSinger:(NSString *)singer { ? = [ ? init]; if ( ? ) { _singer = singer; } return ?; } so this is what I have:
  • ( id) initWithSinger:(NSString *)singer { self = [ ? init]; (not sure here because I have no clue what this class is........) if ( self ) { _singer = singer; } return self; }

Please help me figure out what this quiz is looking for for the class to init. :-)

Thanks!

which quiz is this.

It is under: iOS: Blog Reader: Data Modeling: Designated Initializers and Connivence Constructors : Quiz

1 Answer

Hello! it should be - ( id ) initWithSinger:(NSString *)singer{

                              self = [super init];  
                              if ( self ){
                                       _singer = singer; 
                              } 
                              return self 

}

thank you! I was getting hung up on the class forgetting I should be able to just call super!

You should be using instancetype for initializers now.