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 trialMatteo Fontana
7,211 PointsThe year set is not the correct value
Hi, I don't understand what is the error, can you help me please?
Is an exercise, this is the istruction:"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'."
here my work
NSDictionary *album = @{@"title":@"Abbey Road", @"artist":@"The Beatles"}; NSMutableDictionary *albumMutable = [NSMutableDictionary dictionaryWithDictionary:album]; [albumMutable setObject:@1969 forKey:@"year"];
I check the exercise but continue to give me an error and I don't now why.
Thank you so much Matteo Fontana
1 Answer
cmonk
4,955 PointsYou forgot to make the year a string literal. To fix it, just add quotes around 1969 like this:
NSDictionary *album = @{@"title":@"Abbey Road", @"artist":@"The Beatles"};
NSMutableDictionary *albumMutable = [NSMutableDictionary dictionaryWithDictionary:album];
[albumMutable setObject:@"1969" forKey:@"year"];
Chandler Tayek
5,513 PointsChandler Tayek
5,513 PointsCan you post what you wrote and what the error is?