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


NSDictionary/NSMutableDictionary, literals and key,object sequence.

I need a grey area cleared up regarding 'key/object' sequence vs 'object/key' sequence. So I guess the question is if you use literals when defining dictionary is the sequence always going to be 'key/object' regardless of NSDictionary or NSMutableDictionary. OR does the 'Key/Object' sequence always apply to NSMutableDictionary.

Also when adding to a mutableDictionary is the adding sequence flexible, for example from video it is being added 'object then key' can that sequence be reversed please reference below code from video

//Adding to dictionary, sequence as presented in video [mutableBook setObject:@"1957" forKey:@"year"];

//Can that be written in the following more logical way in line with a //key/object sequence when adding as it feels it would be more tidy [mutableBook forKey:@"year" setObject:@"1957" ];

Sorry the way last two lines turned out, I'm sure you will understand, it presented well in browser before submitting it i must have not pressed enter where two lines joined up.

1 Answer

I would look at this


But as far as I can see it does not look like you can write it the second way. Someone feel free to correct me if I'm wrong.