I cannot understand why this code is bad. I thought using static lines in the dictionaryWithObjectsAndKeys, but this fails at runtime with EXC_BAD_ACCESS. I used a debugger to determine that it does not actually work in the definition line. He never displays "Did it here."
- (NSString *)polyName:(NSUInteger)vertices { NSLog(@"looking for polyName with %d vertices.", vertices); NSDictionary *polNameDict = [NSDictionary dictionaryWithObjectsAndKeys: @"triangle", @"3", @"square", @"4", @"pentagon","5", @"Hexagon", @"6", @"Heptagon", @"7", @"Octagon", @"8", @"Nonagon", @"9", @"Decagon", @"10", @"Hendecagon", @"11", @"Dodecagon", @"12", nil]; NSLog(@"Made it here"); NSString *key = [NSString stringWithFormat: @"%d", vertices]; NSString *polName = [polNameDict objectForKey:key]; return (polName);
source share