Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Code Challenge: Create an NSMutableArray object called 'elements'.

The challenge is asking to to Create an NSMutableArray object called 'elements'.

I tried to create an NSMutableArray object by typing this into the editor: NSMutableArray *elements;

The code challenge editor says I made a mistake, but the code works just fine in Xcode.

Does anyone have any idea what went wrong?

Thanks.

2 Answers

Stefan Bjornsson
Stefan Bjornsson
3,362 Points

For the first task I have tried the 3 following lines of code that does not pass: NSMutableArray *elements; NSMutableArray *elements = [[NSMutableArray alloc] init]; NSMutableArray *elements = [[NSMutableArray alloc] initWithCapacity: 0];

When pushing the preview button I rarely see any display of errors through out this course it usually display blank white space, is it possible to fix that?

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

Try: NSMutableArray *elements = [NSMutableArray array];

Brayden Kness
Brayden Kness
12,492 Points

Did you do @property (strong, nonatomic) NSMutableArray *elements; ?

Not possible since there's no header file.