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 trialJay Caston
3,941 PointsDictionary Challenge Roadblock - mutableDictionary
I'm trying to add the key of NSString 'year' to my NSDictionary and make its value a string '1969'. I copied the instructors code and adapted it directly for this challenge, although I think that the challenge is asking me to make the value a string whereas the instructor's video may not have required the value type to be a string. What should I be doing differently?
NSDictionary *album = @{@"title": @"Abbey Road", @"artist": @"The Beatles"}; NSMutableDictionary *albumMutable = [NSMutableDictionary dictionaryWithDictionary: album]; [albumMutable setObject:@1969 forkey:@"year"];
4 Answers
Holger Liesegang
50,595 PointsHi Jay,
There's a great video on the right "Tips for asking questions" that might help you with posting your code in the forum.
The solution for Challenge task 3 of 3 "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'." is
NSDictionary *album = @{@"title":@"Abbey Road", @"artist":@"The Beatles"};
NSMutableDictionary *albumMutable = [NSMutableDictionary dictionaryWithDictionary: album];
[albumMutable setObject:@"1969" forKey:@"year"];
and the literal @1969 for a NSNumber normally would be ok but you might want to have a look here
Jay Caston
3,941 Pointsthanks so much!
Sean Lee
5,196 PointsThis helped me out! thanks.
Christian Deciga
5,600 Pointshelped me out as well thank you!!