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 Objective-C Basics (Retired) Foundation Framework NSDictionary

Hossam Khalifa
Hossam Khalifa
17,200 Points

Why was the author first not the title?

NSDictionary *book = [[NSDictionary alloc]initWithObjectsAndKeys:@"The cat in the hat",@"title",@"Dr.Seuss",@"author" ,nil];

The Title is written first but the author shows up first when we build the app. Why?

6 Answers

By key, or object? ;-)

You may well be right, yes.

How are the objects and keys called? The above code code sets the pairings but you call them in whichever order you like.

Post the code that displays the entries - I can't remember what it is!

Ah - you've just sent the whole *book to NSLog. I don't think an NSDictionary can be relied upon to output in any particular order, unlike the NSArray. Objects and keys are paired.