IOS의 propertylist에서 키를 정렬하는 데 어려움이 있습니다.키 정렬 값
나는 내가 metode로 정렬 배열 키를 추출하는 것을에서 사전에있는 목록을로드하고 "sortedArrayUsingSelector'selector는 (비교 :"
을 내가 키를 사용하려고하면, 그 값은 거기에 열쇠를 줘서 정렬되지 않은 것 같습니다. exsample에 (키 진값) 정렬되지 않은 : 아 센스 0 덴스 1 Nyborg, 덴마크 1 미델 파르트 0 분류 : 아 센스, 1, 덴 1, 0 Nyborg, 덴마크, 미델 파르트 0
`
NSBundle *bundle = [NSBundle mainBundle];
NSURL *KSplistURL = [bundle URLForResource:@"KommunerStedtillæg"
withExtension:@"plist"];
NSDictionary *dictionary = [NSDictionary
dictionaryWithContentsOfURL:KSplistURL];
self.kommuner = dictionary;
//NSArray *keys = [[self.kommuner allKeys] sortedArrayUsingSelector:@selector(compare)];
NSArray *components = [self.kommuner allKeys];
NSArray *keys = [components sortedArrayUsingSelector:@selector(compare:)];
NSMutableDictionary *newDict = [NSMutableDictionary dictionary];
for (id key in keys)[newDict setObject:[dictionary objectForKey:key]forKey:key];
self.kommunerKeys = [newDict allKeys];
self.kommunerValues = [newDict allValues];
`
코드 스 니펫을 게시하십시오! – DPlusV