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 trialCaleb Kleveter
Treehouse Moderator 37,862 PointsI can't figure out whats wrong with my code.
Whats wrong with my code? I can't figuer it out.
[albumMutable setObject:@1969 setKey:@"year"];
NSLog(@"%@", albumMutable);
Here is the warning:
instance method '-setObject:setKey:' not found (return type defaults to 'id')
[albumMutable setObject:@1969 setKey:@"year"];
^~~~~~~~~~~~~~~~~~~~~~
note: receiver is instance of class declared here
@interface NSMutableDictionary : NSDictionary
^
1 error generated.
8 Answers
Andres Oliva
7,810 PointsOk, I know what's going on.
The challenge task reads: 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'.
That means your code should be:
[albumMutable setObject: @"1969" forKey: @"year"];
Not
[albumMutable setObject: @1969 forKey: @"year"];
I just tried it and it works.
KP Cluff
2,344 PointsWhat are you workng on?
Caleb Kleveter
Treehouse Moderator 37,862 PointsThe NSDictionary challenge, Foundation Framework badge, in the Objective-C Basics course; I'm on step 3.
Caleb Kleveter
Treehouse Moderator 37,862 PointsIf you need more code I can give it to you.
Andres Oliva
7,810 PointsThat means that the method you're calling doesn't exist.
If I understand correctly, what you need is this:
[albumMutable setObject: @1969 forKey: @"year"];
Caleb Kleveter
Treehouse Moderator 37,862 PointsOkay, I got it.
Caleb Kleveter
Treehouse Moderator 37,862 PointsIt said my answer was wrong: Bummer! The year set is not the correct value.
Caleb Kleveter
Treehouse Moderator 37,862 PointsGot it! Thank you!