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 Object-Oriented Objective-C Getting Oriented - Object-Oriented, That Is Review NSDictionaries and NSMutableDictionaries

Luis Paulino
PLUS
Luis Paulino
Courses Plus Student 1,779 Points

I need help with the second part of the challenge, but I can't ask for help the help button broken.

I have to assign a string value key for artdict? I'm sorry

variable_assignment.mm
NSDictionary *artDict= @{
                          @"Artist":@"Dali",
                          @"Title":@"The Ship",
                          @"Medium":@"Oil Paint",
};

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,857 Points

Hi Luis.

First off, the help button seemed to work okay. The challenge and your code is linked properly.

Now, for task two, you will need to create a new string variable and then using valueForKey assign the value from the Key "Artist" to the new String variable.

Below is the code needed for you to review. Have a look. If it still doesn't quite make sense, then have a quick look back at the video for review. :)

NSString *favoriteArtist = [artDict valueForKey:@"Artist"];

Keep Coding! :dizzy:

Luis Paulino
Luis Paulino
Courses Plus Student 1,779 Points

It's still not working maybe it's my computer? Where do I put this string in or out of the NSSDict?

Jason Anders
Jason Anders
Treehouse Moderator 145,857 Points

Hey Luis Paulino

Not sure if you have it figured yet or not. You first part is correct.

Yes, Assigning the value to the String needs to be done outside of the Dictionary. So, the final code will look like

NSDictionary *artDict= @{
                          @"Artist":@"Dali",
                          @"Title":@"The Ship",
                          @"Medium":@"Oil Paint",
};

NSString *favoriteArtist = [artDict valueForKey:@"Artist"];

I did run the code through the challenge and it passed both, so I hope it worked out for you :) :dizzy:

Luis Paulino
PLUS
Luis Paulino
Courses Plus Student 1,779 Points

Thank you, Jason sorry to be a bother you where a big help