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 trialKevin Blair
5,230 PointsLearning the Language> Code Challenge: Getting to Know Arrays> 2nd Step
Code Challenge Question:
Access the first fruit in your array.
Here is my code. Please tell me if you see anything wrong when trying to locate the first fruit in my array. The system has already approved my first line of code. The second part keeps coming back wrong for some reason.
NSArray *myArray = [[NSArray alloc] initWithObjects: @"Apple", @"Orange", @"Banana", @"Plum", nil];
self.myLabel.text = [myArray objectAtIndex:0];
Thanks!
5 Answers
James Barnett
39,199 PointsKevin - I haven't done the iOS course yet, so I won't but much help. However, here's a suggestion from, your friendly neighborhood mod ...
You might get better responses to your query if, you took a look our featured post on how to ask good questions on the forum
Kevin Blair
5,230 PointsThanks James Barnett for your quick response. This was my first post, so I edited it to your format. Please pass on to anyone you know who might be able to help me with my code!
James Barnett
39,199 PointsKevin - Your edited post looks much better. I made one small change and added markdown so your code is formatted properly by the forum.
samiff
31,206 PointsHey Kevin, I think I found a solution to your problem using the new Search feature for the forums, hope it helps!
via: Cannot Pass Introduction to Arrays Code Challenge
...in the second line you are assigning the value returned from the myArray to a label but in this case, it is non-existent. It exists in the context of the project but the Code Challenge does not test against variables or properties declared within the project. Hence, your answer [myArray objectAtIndex:0]; is perfect, just don't assign it to a label. ā <cite>Amit Bijlani</cite>
Kevin Blair
5,230 Points@ James - Thank you for doing that.
@Sam - It worked! Thanks for that information and link to that blog!