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 trialJasper Hamilton
501 PointsNSDictionary Challenge 3/3
The question is asking me "Let's add the year of the album to the 'albumMutable' variable. Where the key is a NSString 'year' and the value is also a NSString '1969'."
The error message is "Bummer! There is a compiler error. Please click on preview to view your syntax errors!", but when I click on view it gives me a blank area where my result/error should be.
My code is as following:
NSDictionary *album = @{ @"title":@"Abbey Road", @"artist":@"The Beatles" }; NSMutableDictionary *albumMutable = [NSMutableDictionary dictionaryWithDictionary:album]; [albumMutable setObject:@1969 forKey:"year"];
What am I doing wrong?
1 Answer
Matthew Mascioni
20,444 PointsHi Jasper,
Your problem lies in your third line:
[albumMutable setObject:@1969 forKey:"year"];
The question is telling us that the value is an NSString, as well as the key. Recall that you declare an NSString literal like this:
@"This is a string literal"
So, in your setObject parameter, you have the @ symbol, but are missing the surrounding quotes. You're also missing something in the value of your forKey parameter.
Have fun!
Jasper Hamilton
501 PointsJasper Hamilton
501 PointsOk, Thanks!