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

iOS

Trae Cadenhead
Trae Cadenhead
6,774 Points

Stuck on a Code Challenge in Build a Simple iPhone App with Objective C

Hello, I'm trying to get past a code challenge in "Build a Simple iPhone App with Objective C." I'm pretty positive my code response is correct (the preview isn't showing any errors), but it won't let me pass saying I have to add all three items to the array (which I am). I'm also including a screenshot.

The URL for the challenge is https://teamtreehouse.com/library/build-a-simple-iphone-app-with-objectivec/creating-a-data-model/creating-a-data-collection-2

My line of code for initializing the array:

[self.shoppingList initWithObjects: @"toothpaste", @"bread", @"eggs", nil];

Screenshot here: https://www.dropbox.com/s/4ikazdw40lkry4l/treehouse%20screenshot.png?dl=0

1 Answer

You need to initialize the array before you can use it

self.shoppingList = [[NSArray alloc]initWithObjects: @"toothpaste", @"bread", @"eggs",nil];

what you have in the screen shot is basically:

["toothpaste", "bread", "eggs"]
Trae Cadenhead
Trae Cadenhead
6,774 Points

Ah, that makes sense. Thanks Marlon!

No problem anytime I can help is a good day for me. When you can explain it to someone that means you really understand what you are doing(and means I'm getting paid to do this in my day job for a real reason lol.) don't forget to mark me as the best answer, trying to get these treehouse points anyway I can lol.