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 trialTossy Kelly
Courses Plus Student 2,069 PointsNSDictionary Challenge task1
The challenge states: Declare an NSDictionary variable named 'album'. Assign the following key/pairs to it: "title" - "Abbey Road", "artist" - "The Beatles".
I entered the following solutions:
- NSDictionary *album = @{@"title":@"Abbey Road",@"artist":@"The Beatles"};
- NSDictionary *album = [[NSDictionary alloc] initWithObjectsAndKeys:@"title",@"Abbey Road",@"artist",@"The Beatles", nil];
however, for both the above attempts the system returned the message: Bummer! your album dictionary has no values.
What am I doing wrong?
1 Answer
Stone Preston
42,016 PointsI tried your first line of code and passed fine using
NSDictionary *album = @{@"title":@"Abbey Road",@"artist":@"The Beatles"};
so im not sure what was wrong but it should have worked
however there is an error in the second way you tried. If you use that method the values come before they keys like so:
NSDictionary *album = [[NSDictionary alloc] initWithObjectsAndKeys:@"Abbey Road",@"title",@"The Beatles", @"artist", nil];