Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,623 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,623 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