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

NSDictionary *album = [[NSDictionary alloc] initWithObjectsAndKeys:@"title", @"Abbey", @"artists", @"The Beatles", nil];

I tried above code many times. It simply does not work. I am stuck here. Need help

Previous few people post same problem and some solution. However no useful. Thanks

could you post a link to the challenge you are referring to

Previous discussion on same topic link : https://teamtreehouse.com/forum/having-problem-with-nsdictionary

4 Answers

NSDictionary *album = [[NSDictionary alloc] initWithObjectsAndKeys:@"title", @"Abbey", @"artists", @"The Beatles", nil];

the key artists probably needs to be singular (artist not artists) and the title is Abbey Road, not just Abbey

maybe try

NSDictionary *album = [[NSDictionary alloc] initWithObjectsAndKeys:@"title", @"Abbey Road", @"artist", @"The Beatles", nil];

ah, I noticed also you are inserting the objects and keys in the wrong order. The object comes first, then the key. try using

NSDictionary *album = [[NSDictionary alloc] initWithObjectsAndKeys:@"Abbey Road", @"title",  @"The Beatles", @"artist", nil];

so the things that were incorrect were you were inserting your key value pairs in the wrong order, you used artists instead of artist as your key, and Abbey instead of Abbey Road as a value.

I tried again does not work. ERROR message: Bummer! Your 'album' dictionary doesn't have any values in it. thanks for reply with in short time

Now I got it. Awesome . Thanks you.