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
Ludwing Najera
4,596 Pointshave not allocated and initialized object "quotes"
here is my code:
if (_predictions == nil){ _predictions = [[NSArray alloc] initWithObjects: @"It is Certain",@"It is Decidedly so",@"All signs say YES", nil];
please reply if you know what to do
(title is problem)
1 Answer
David Jobe
18,617 PointsLooks like you are trying to lazy initialize an array. So in the getter method you initialize the array if it has not already been created. I'm also new to programming so I could be wrong but if not, I would do it like this.
-(NSArray *)_predictions { if (!_predictions) _predictions = [[NSArray alloc] initWith.... //Don't forget to return it. return _predictions; }
Please let me know if this was any help at all =) Cheers