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

John Maden
John Maden
1,525 Points

I'm Not Sure How To Solve This Problem

I've tried a variety of options including:

NSDictionary *album = @{ @"title":@"Abbey Road", @"artist":@"The Beetles" };

NSDictionary *album = [[NSDictionary alloc]initWithObjects: @[@"Abbey Road", @"Beatles"] forKeys:@[@"title", @"artist"]];

I'm currently getting that my album has no definitions. I'm not sure what it is asking for.

2 Answers

Stone Preston
Stone Preston
42,016 Points

your first solution will work, however you misspelled the artists name which is causing the errors. Its "The Beatles" not "The Beetles"

NSDictionary *album = @{ @"title":@"Abbey Road", @"artist":@"The Beatles" };

the second one will work as well, but you also have the incorrect artist name. It should be "The Beatles" not "Beatles"

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

so you just had some minor typos that were causing your code to fail

John Maden
John Maden
1,525 Points

haha thank you, I had 3 iOS developers in my company look at the code and it took us 25 minutes to realize that was the error.

Thank you :)