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!
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
Learning the Language > Code Challenge: Getting to Know Arrays
Still cant get passed 2/2, how do i acces the first fruit in array from this. Should this "self.predictionLabel.text " be something else, there are no instructions that I can find in vid. And why is the video training making a crystal ball and the challenge about fruit, it seems odd. I have taught in the past, and there seems to be continuity errors here between vid and challenge...remember Treehouse, we are probably newbies, spoon feed us please.....or at least I can only speak for myself.......Ive been trying to solve this for well over a week now.
NSArray *myArray = [[NSArray alloc] initWithObjects: @"Apple",@"Orange",@"Banana",@"Plum",nil];
self.predictionLabel.text = [myArray objectAtIndex:0];
Amit BijlaniTreehouse Guest Teacher
Sorry you are having trouble. The goal of Code Challenges are not to make you simply type what you saw in the video. The goal is to see if you can apply what you learned in the video in a different context. Hence the reason for fruits in the Code Challenge. Your answer is right except that you are not setting the value you access from the array to any label. The Code Challenge is simply to test to see whether you can create an array and know how to access an object. There is no UI so there is no label.
So your second line will simply be:
J.T. Gralka20,126 Points
I don't think you have to do anything with a UILabel, so you should just be able to access the array at a particular index by doing something like this:
[myArray objectAtIndex:0]; // Get the first element of the array...
Hope this helps,
It looks like Amit answered this question before I did; sorry for reiterating what was already said! Hopefully you're on the right track now!
Ahh thanks, I can see now.. Feeling a little humbled and less stressed, thanks guys :)