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

Jimmy Boone
Jimmy Boone
8,940 Points

Why am I told my Dictionary does not contain any values?

I have copied the format from the video exactly and I am still getting a "Your Dictionary doesn't contain any values error"

nsdictionary.mm
NSDictionary *album = @{@"title":@"Abby Road", @"artist":@"The Beatles"};

2 Answers

Naomi Freeman
STAFF
Naomi Freeman
Treehouse Guest Teacher
NSDictionary *album = @{@"title":@"Abbey Road",@"artist":@"The Beatles"};

Hmmm, this ^ works. Stared at a for a couple minutes. I think you're just missing the e in Abbey Road. I could be wrong. It's throwing a funny error for that, but eh - give it a shot :)

Naomi Freeman
Naomi Freeman
Treehouse Guest Teacher

While we're all here - any idea why my code has stopped being colourful when I post?

Stone Preston
Stone Preston
42,016 Points

add a language after the 3rd back tick. you can use c or objective c:

```objective-c
Stone Preston
Stone Preston
42,016 Points

the challenge may not like your use of the literal syntax. try using initWithObjectsAndKeys:

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

this will work but is this part of the scope on his module? I'm afraid he will get confused... just saying.. :)

Stone Preston
Stone Preston
42,016 Points

yes it is indeed part of the scope of this module. see 1:35 of this video.

Doug uses the init with objects and keys method, not a literal. literals (besides string literal) are actually not part of the scope of this course, which is why I thought the challenge may not have accepted his literal syntax.

Dave Abalos
Dave Abalos
6,976 Points

ohh yeah.. thanks for the refresh... :)