NSDictionary のキーの値を取得しようとしています。ディクショナリは、両方とも文字列型のキーと値のペアで初期化されています。問題は、objectForKey または valueForKey を呼び出しても値を取得できないように見えることです。
辞書を反復処理して、キーと値の両方を出力できます。
誰かが間違っているところを指摘できますか? これが私のコードです...
//Set up dictionary with options
keys = [NSArray arrayWithObjects:@"red", @"blue", nil];
values = [NSArray arrayWithObjects:@"1.7", @"2.8", nil];
conversionOptions = [NSDictionary dictionaryWithObject:values
forKey:keys];
次に、これはピッカーの選択行で呼び出されます
NSLog(@"... %@", [keys objectAtIndex:row]); //prints out the key
NSString *theString = [keys objectAtIndex:row]; //save it as a string
NSLog(@"The string is... %@", theString); //print it out to make sure im not going crazy
NSLog(@"the value is : %@",[conversionOptions objectForKey:theString]); // I just get NULL here
//NSLog(@"the value is : %@",[conversionOptions valueForKey:theString]); // This doesn't work either, I just get NULL