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 Memory, Arrays and Loops, Oh My! Alloc and Init

Andre Robinson
PLUS
Andre Robinson
Courses Plus Student 6,057 Points

Please help

Someone please help I don't Know what I'm doing wrong how do i give myRide the make value in carDict

variable_assignment.mm
NSMutableDictionary * carDict= [[ NSMutableDictionary alloc ] initWithObjectsAndKeys: @"Honda",@"Make",@"Accord",@"Model",nil];

NSString* myRide= [[NSString alloc] init];

myRide = [NSMutableDictionary  carDict] initWithvalueForKey:@"Make"];

3 Answers

Hi Andre,

You've got that nearly right ... first, carDict doesn't need re-typing; i.e. we know it's an NSMutableDictionary. Next, we want to use the valueForKey method and pass the @"Make" key to that. This looks like:

myRide = [carDict valueForKey: @"Make"];

Make sense?

Steve.

Brian Lopez
Brian Lopez
1,124 Points

man, i am lost. i feel like I'm basically reading the message board 60% of the time for my tests. this helped me, but I'm not sure if i should keep moving along, or slow down

Hi Brian,

It is difficult to say what's best for you to do. You're new to this, and you've chosen Objective C which is a tricky language. Slowing down may help - or maybe think about your goals and whether Obj C is the best starting point?

Steve.

Brian Lopez
Brian Lopez
1,124 Points

yeah it is pretty difficult, haha. Its not so much the concepts themselves sometimes, its the memorization and when to use what, and also to know what you did wrong. I only have one goal, to make an iPhone app.

OK - making an iPhone app these days is probably best done in Swift rather than Objective C. I say probably; I meant certainly! Obj C is useful for managing existing iOS applications. Making new ones requires Swift as that's the updated language being used now. It is a little more straightforward than Obj C as it is more modern.