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

Struggling with Code Challenge: Getting to Know Arrays

I wrote the code as:

*myArray = = [[NSArray alloc] initWithObjects:@"Apple", @"etc", nil;

But I can't seem to get it right. Can anyone help me on where I went wrong?

Thanks,

Vince

7 Answers

Right off the bat,

  1. You have two "=" signs
  2. You have two "[" and one "]".

A variable will always be in this form:

NSString *myName = @"Ernest";

You forgot to add your last ] and our only need one =

*myArray = [[NSArray alloc] initWithObjects: @"Apple", @"Orange", @"Banana", @"Plum", nil];

Tried to fix it with this but it still didn't work. Am I missing something else?

Thanks guys, much appreciated

Yea, you forgot the class: NSArray *myArray= .......

Legend! Thanks!

Don't forget your class. The variable is always referring to the class. It keeps your code readable and for the compiler to understand your code.