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, Code Challenge NSDictionary

I got error "The year set is not the correct value."

this is the code

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

NSMutableDictionary *albumMutable = [NSMutableDictionary dictionaryWithDictionary:album];

[albumMutable setObject:@1969 forKey:@"year"];

I guess someone miss-typed a year? Douglass Turner thanks!

6 Answers

Holger Liesegang
Holger Liesegang
50,595 Points

Does using setObject:@"1969" get you past? (yeah I know that @1969 for a NSNumer is totally ok :-) )

Ben Jakuben
Ben Jakuben
Treehouse Teacher

I believe this is a bug in this code challenge that has been logged and should be fixed shortly. As Holger suggested, try @"1969". :)

yap, that worked, thanks guys!

Douglass Turner
STAFF
Douglass Turner
Treehouse Guest Teacher

Guys,

@"123" is an NSString literal. @123 is an NSNumber literal.

Either can be used as key/value.

Douglass Turner
STAFF
Douglass Turner
Treehouse Guest Teacher

[albumMutable setObject:@1969 forKey:@"year"] can be rewritten as:

[album setObject:[NSNumber numberWithInteger:1969 forKey:@"year"]];

try that

Danielle Quevedo
Danielle Quevedo
17,935 Points

Putting "1969" in quotes is the only way to go. The instructions say "...and the value is also a NSString '1969' ", so that's why leaving it as an integer (outside of quotes) won't work.

Right, with the quotation marks the challenge went through successfully for me. :@"1969" is what needed to happen.