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 trialCalvin Hu
670 PointsHow to fix expected identifier with NSMutableDictionary?
NSArray *shoeOrder = @[@"Charles Smith",@(9.5),@"loafer",@"brown"];
NSMutableDictionary *shoeOrderDict = [[NSMutableDictionary alloc] init];
NSMutableDictionary *shoeOrderDict [[NSMutableDictionary]objectAtIndex:0];
This is my full code, I am trying to add the values in the Array into the NSMutableDictionary, must use objectAtIndex.
NSArray *shoeOrder = @[@"Charles Smith",@(9.5),@"loafer",@"brown"];
NSMutableDictionary *shoeOrderDict = [[NSMutableDictionary alloc] init];
NSMutableDictionary *shoeOrderDict [[NSMutableDictionary] objectAtIndex:0];
2 Answers
Emil Rais
26,873 PointsYou performed correctly the first step where you allocate and initialise your dictionary. The next thing you need to do is to assign each value from the array to the dictionary using the corresponding key.
So you would do something like the following 4 times - once for each key.
shoeOrderDict[@"key"] = [shoeOrder objectAtIndex: index]
Janson Roberts
5,071 PointsThis didn't work for me. Still stuck...not fully even understanding how this is supposed to work for multiple objectAtIndex. What's wrong here?