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 trialEsma Goktekin
3,870 PointsSwitch to the implementation file and implement a 'quotes' method which will allocate and initialize the _quotes instanc
I don't know what is wrong with my answer. Any help will be greatly appreciated. -(NSArray *) quotes{ if(_quotes == nil) { _quotes = [[NSArray alloc] initWithObjects:@"a",@"d",@"c",nil];} return _quotes; }
Pierre Thalamy
4,494 PointsPlease refer to the Markdown Cheatsheet on how to format your code when posting on the forum, it makes it much easier to read it! ;)
(NSArray *) quotes {
if (_quotes == nil) {
_quotes = [[NSArray alloc] initWithObjects:@"a",@"d",@"c",nil];
}
return _quotes;
}
Let me have a look at this.
2 Answers
Pierre Thalamy
4,494 PointsI have just done it once again to check and this is the correct answer:
- (NSArray *) quotes {
if (_quotes == nil) {
_quotes = [[NSArray alloc] initWithObjects:@"1", @"2", @"3", nil];
}
return _quotes;
}
Which is exactly the same as yours, but it seems that you forgot the - before the method implementation. What that the problem?
Esma Goktekin
3,870 PointsThanks :)
Christian McMullin
13,086 Points- (NSArray *) quotes {
if (_quotes == nil) {
_quotes = [[NSArray alloc] initWithObjects:@"foo", @"bar", @"car", nil];
}
return _quotes;
}
this was my answer and its not working. Did I miss something? Looking at this forum it looks like I did it right. It's saying I'm wrong.
Christian McMullin
13,086 PointsNevermind, I had messed up calling my property.
Esma Goktekin
3,870 PointsEsma Goktekin
3,870 PointsStage 4 Refactoring into a Model