2012-06-01 5 views
-3

저는 iPhone을 처음 사용합니다. 난 내가 한 배열에 이러한 모든 (키) 이름을 얻을 수있는 방법 나의 의심은이plist에있는 모든 키 이름을 배열로 가져 오는 방법

key    Type  Value 
Genesis   Array  (50items) 
Exodus   Array  (40items) 
Leviticus   Array  (30items) 
Numbers   Array  (20items) 

같은 PLIST의 외모를 가지고있는 작은 의심의 여지가? 즉 창세기, 출애굽기, 레위기, 민수기의 이름을 가진 배열이 필요합니다.

답변

2

allKeys을 살펴보십시오. 이것은 당신이 키에 의해 정렬 할 경우,해서 AllKeys에 의해 반환 된 배열은 당신이 사용 keys 배열을 정렬 할 필요는 PLIST에있는 키의 순서를 반영하지 수 NSDictionary

NSString *path = [[NSBundle mainBundle] bundlePath]; 
NSString *finalPath = [path stringByAppendingPathComponent:@"file.plist"]; 
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:finalPath]; 
NSArray *keys=[dict allKeys]; 

한 주에 포함 된 모든 키를 반환 일부 comparator.

0
NSString *path = [[NSBundle mainBundle] pathForResource: @"yourPlist" ofType: @"plist"]; 
NSDictionary dict = [NSDictionary dictionaryWithContentsOfFile: path]; 
NSArray *myarray = [dict allKeys]; 
//NSArray *myarray = [dict allValues];//if Values Required the use allValues... 
관련 문제