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 trialTera Tarbet
1,212 PointsGot past the 2nd task of this quiz and the message is that their is a syntax error on the for code...what is the prob?
NSDictionary *album = @{@"title":@"Abbey Road",@"artist":@"The Beatles"}; NSMutableDictionary *albumMutable = [NSMutableDictionary dictionaryWithDictionary:album]; [albumMutable setObject:@1969 forKey:@"year"]; for (NSString *string in [albumMutable allKeys]) { NSLog(@"key %@ value %@", string, [albumMutable objectForKey:string]); }
3 Answers
Holger Liesegang
50,595 PointsHi Tera,
you were asked to use 1969 as a string and that would be @"1969" as @1969 builds a NSNumber and this should work:
[albumMutable setObject:@"1969" forKey:@"year"];
I just tested Challenge task 3 of 3 of "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'." with
NSDictionary *album = @{ @"title":@"Abbey Road", @"artist":@"The Beatles" };
NSMutableDictionary *albumMutable = [NSMutableDictionary dictionaryWithDictionary:album];
[albumMutable setObject:@"1969" forKey:@"year"];
and it passed the test.
Holger Liesegang
50,595 PointsOh, and of course welcome to Treehouse, Tera Tarbet
... also there's a great video here in the forum section on the right "Tips for asking questions" that might help you with posting your questions and code on the forum.
...and keep on coding :)
Tera Tarbet
1,212 PointsThanks for the help! I watched the video...thanks for the tip!