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
Paul Cisneros
1,178 PointsQuiz - Access the first fruit in your array - What's wrong with the code?
I'm trying to pass this stage, but can't and have formatted the code exactly like the video example.
NSArray *myArray = [NSArray alloc]; myArray = [myArray initWithObjects:@"Apple",@"Orange",@"Banana",@"Plum",nil]; self.predictionLabel.text = [myArray objectAtIndex:0];
I've also tried this:
NSArray *myArray = [NSArray alloc]; myArray = [myArray initWithObjects:@"Apple",@"Orange",@"Banana",@"Plum",nil]; // Without predictionLabel self.text = [myArray objectAtIndex:0];
1 Answer
Amit Bijlani
Treehouse Guest TeacherThe challenge is simply asking you to access the first fruit. It's not asking you to assign it to a label or text.
So your last line should be:
[myArray objectAtIndex:0];
Paul Cisneros
1,178 PointsPaul Cisneros
1,178 PointsThanks! That worked. I didn't think about not assigning it to a label or text. Next time, I will!