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

NSArray of NSDictionay syntax question

I am currently having a go at my first iOS app.

Xcode tells me it expects an expression where I put the closing brackets. Though when I look at the Apple developer documentation, from what I can see this is the proper way to do it. Obviously I’m wrong. Could anyone point out to me exactly what I’m doing wrong?

Here is a sample of the code I've written. The full code has more dictionaries following the same template.

NSDictionary *theMoose = @{

                           @"The Moose": @"title",
                           @"a description" : @"challengeDescription",
                           @"theMoose1.png, theMoose2.png, theMoose3.png": @"animation", nil:

                        };



challenges = [NSArray arrayWithObjects: theMoose, nil];

2 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

With literals you do not need to nil terminate.

NSDictionary *theMoose = @{
                           @"The Moose": @"title",
                           @"a description" : @"challengeDescription",
                           @"theMoose1.png, theMoose2.png, theMoose3.png": @"animation"
                        };

Thanks a bunch Amit.

Class A course you've set up btw.