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 Build a Simple iPhone App (iOS7) Refactoring into a Model Creating a Custom Class

Trouble with "Creating a Custom Class"

Hi,

can anyone help me out with the following ? The system kept giving me the Bummer: Remember to allocate and initialize the instance variable '_quotes' and return it from the method named 'quotes'.

This is how my Implementation-File looks like:

#import "Quote.h"

@implementation Quote

- (NSArray*) quotes {
if (_quotes == nil)
_quotes = [[NSArray alloc] initWithObjects:@"Hi", @"Hello", @"Hola", nil]];

return _quotes;
}

- (NSString*) randomQuote {

return @"Some Quote";
}

@end

3 Answers

Holger Liesegang
Holger Liesegang
50,595 Points

Welcome to Treehouse, Samet Aslan !

You just had one square Bracket to much and one curly bracket was missing :)

- (NSArray*) quotes {
    if (_quotes == nil) {
        _quotes = [[NSArray alloc] initWithObjects:@"Hi", @"Hello", @"Hola", nil];
        };
    return _quotes;
}
Scott Evans
Scott Evans
4,236 Points

Well spotted, i didn't notice the extra ]

Holger Liesegang
Holger Liesegang
50,595 Points

Scott Evans It's so much easier in Xcode, isn't it :-)

Scott Evans
Scott Evans
4,236 Points

Holger Liesegang indeed it is! But unfortunately I'm not at my mac :(

Thank you for the quick response, it fixed my problem and i can now head on!

Deanna Robertazzi
PLUS
Deanna Robertazzi
Courses Plus Student 2,447 Points

This code doesn't work on my iPad or my mac. I'm typing it in exactly. What's wrong with this?