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 trialKeith Shadle
1,290 PointsWhat is wrong with my code in this challenge. ? Task 2 Many thanks.
import "Quote.h"
@implementation Quote
(NSArray*) quotes { if (_quotes == nil) { _quotes = [[NSArray alloc] initWithObjects:@"This is hard",@"That is ok", nil]; }
-
(NSString *) randomQuote {
return @"Some Quote"; }
@end
1 Answer
Peter Simpson
Courses Plus Student 15,526 PointsI'm not quite sure what the question is asking for, but I think your code should look like this? '''
- (NSArray *) quotes {
if (_quotes == nil) _quotes =[[NSArray alloc]initWithObjects: @"This is hard", @"That is ok", nil]; return _quotes; }
'''
Mike Baxter
4,442 PointsMike Baxter
4,442 PointsI recommend giving the OP code that scopes the if statement in curly braces to help avoid further errors.
I agree with Peter's answer. Peter's code looks like this with those:
Make sure _quotes is listed in your Quote.h file too, Keith. Cheers!
Keith Shadle
1,290 PointsKeith Shadle
1,290 PointsThanks for the help, Gents! Got me past the quiz. Best! K