2011-12-21 3 views
0

내 PLIST은 다음과 같다 : 눈 atIndex :배열에서 사전의 항목을 선택 하시겠습니까?

<array> 
    <dict> 
     <key>eye</key> 
     <string>eye_man_blue</string> 
     <key>lips</key> 
     <string>lips_blue</string> 
    </dict> 
    <dict> 
     <key>eye</key> 
     <string>eye_man</string> 
     <key>lips</key> 
     <string>lips</string> 
    </dict> 
</array> 

은 내가/선택 "eye_man_blue"forkey을 읽을 필요가 0. NSLog (@ "% @. png", eyeDisplay);
이 기록에 가정 :

arrayItems=[NSMutableArray arrayWithContentsOfFile:finalPath]; 
NSArray *itemArray = [NSArray arrayWithObjects:[arrayItems objectAtIndex:0], nil]; 
NSDictionary *itemdict = [NSDictionary dictionaryWithObject:itemArray forKey:@"eye"]; 
NSLog(@"%@",itemdict); 

내가 얻을 :

2011-12-21 11:00:30.749 project[358:f803] { 
    eye =  (
    ); 
} 

답변

1

당신은 2 인덱스 1 개 배열을 가지고, 각 인덱스는 사전입니다 eye_man_blue.png
내가 좋아하는 뭔가를 시도했다.

arrayItems=[NSMutableArray arrayWithContentsOfFile:finalPath]; 
NSString *myString = [[arrayItems objectAtIndex:0] objectForKey:@"eye"]; 
NSLog (@"%@.png",myString); 
+0

자동 참조 계산 문제 : 선택에 대한 알려진 인스턴스 메소드 'forKey :' – Albert

+0

나는 그것이 내 코드를 업데이트'objectForKey : 매력처럼' – syclonefx

+0

일 – Albert

관련 문제