1
특정 키에서 단일 키 값에 액세스하려면 어떻게합니까?사전 배열 내의 특정 키 값에 액세스하는 방법
아래와 같이 plist 소스와 함께 NSDictionary의 NSArray를 사용하고 있습니다.
<plist version="1.0">
<array>
<dict>
<key>name</key>
<string>item name</string>
<key>level</key>
<integer>3</integer> // range is 1 .. 7
<key>Stage1</key>
<string>Text for Stage 1</string>
<key>Stage2</key>
<string>Text for Stage 2</string>
<key>Stage3</key>
<string>Text for Stage 3</string>
<key>Stage4</key>
<string>Text for Stage 4</string>
<key>Stage5</key>
<string>Text for Stage 5</string>
<key>Stage6</key>
<string>Text for Stage 6</string>
<key>Stage7</key>
<string>Text for Stage 7</string>
</dict>
// more dictionaries follow
나는 다음을 수행하여 전체 사전을 볼 수 있습니다
NSNumber *helps = [myArray objectAtIndex:[pickerView selectedRowInComponent:0]];
notesLabel.text = [NSString stringWithFormat:@"%@", helps];
당신의 도움이 크게 감사합니다 ... 나는 그런 멍청한 놈입니다.
참 고맙습니다! 다음을 추가 할 수있었습니다 :
NSDictionary *dictionary = [foodArray objectAtIndex:[pickerView selectedRowInComponent:0]];
notesLabel.text = (@"stage is: %@", [dictionary objectForKey:[NSString stringWithFormat:@"%@", stage]]);
내가 누락 된 부분을 정확히 알려줍니다. :)
, 도움을 주셔서 감사합니다! – padapa
은 내가 좋아하는 것처럼 매력적으로 작동했습니다. – padapa