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 trialSamet Aslan
535 PointsTrouble 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
50,595 PointsWelcome 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;
}
Samet Aslan
535 PointsThank you for the quick response, it fixed my problem and i can now head on!
Deanna Robertazzi
Courses Plus Student 2,447 PointsThis code doesn't work on my iPad or my mac. I'm typing it in exactly. What's wrong with this?
Scott Evans
4,236 PointsScott Evans
4,236 PointsWell spotted, i didn't notice the extra
]
Holger Liesegang
50,595 PointsHolger Liesegang
50,595 PointsScott Evans It's so much easier in Xcode, isn't it :-)
Scott Evans
4,236 PointsScott Evans
4,236 PointsHolger Liesegang indeed it is! But unfortunately I'm not at my mac :(