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 trialMarco Garduño
1,549 Pointswhats wrong?
what am i missing???
NSMutableDictionary*carDict=[[NSDictionary alloc] initWithObjectsAndKeys:"Make":"Honda","Model":"Accord" , nil];
3 Answers
Sam Chaudry
25,519 PointsHi Marco you've got an incompatible pointer type you've declared NSDicitonary and pointed it to a NSMutableDictionary so thats where you've gone wrong. Try the solution below that will get you through the code challenge.
NSMutableDictionary * carDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Accord",@"Model",@"Honda",@"Make", nil];
ARMANDO RODRIGUEZ
4,216 PointsNo this thing is broken.
I've tried both ways of initializing an NSMutableDictionary in one line and both fail the code check.
NSMutableDictionary *carDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Make", @"Honda", @"Model", @"Accord", nil];
This one fails.
NSMutableDictionary *carDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Make", @"Honda", @"Model", @"Accord", nil];
This one fails too. Those are the ONLY ways to do it in one line.
The only way to do it other than that is two lines...
NSMutableDictionary *carDict = [NSMutableDictionary alloc];
[carDict initWithObjectsAndKeys:@"Make",@"Honda",@"Model",@"Accord",nil];
There's something wrong with the test.
Shannon Gold
4,426 PointsI tried answering the test like this because it's similar syntax to the sample in the previous video. However, I'm also getting a syntax error.
NSMutableDictionary *carDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys: @"Make", @"Honda", @"Model", @"Accord", nil];
Then, I dug deeper and found this which works.
NSMutableDictionary *carDict = [[NSMutableDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"Honda", @"Accord", nil] forKeys:[NSArray arrayWithObjects:@"Make", @"Model", nil]];