2014-04-11 2 views
-1

에 의해 나는정렬 NSMutableDictionary 순

난 당신이 사전 자체를 정렬 할 수 없습니다이

{A,B,C,D} -> {custom obj2, custom obj1, custom obj4, custom obj3} 
+1

사전을 정렬 할 수 없습니다. 키를 정렬 한 다음 정렬 된 키를 기반으로 개체에 액세스 할 수 있습니다. – rmaddy

+2

가능한 중복 [어떻게 NSMutableDictionary 키 값으로 정렬 할 수 있습니까?] (http://stackoverflow.com/questions/8118932/how-can-i-sort-nsmutabledictionary-with-keys-value) – rmaddy

답변

0

으로 정렬 싶습니다 NSMutableDictionary keys {B,A,D,C}values {custom obj1, custom obj2, custom obj3, custom obj4}있는 경우. 그러나 키 배열 [dictionary allKeys]을 가져 와서 정렬 할 수 있습니다. 예 :

NSMutableArray mutableKeys = [[dictionary allKeys] mutableCopy]; 
[mutableKeys desiredSortingMethod]; 
+0

그리고 예, 지금 깨달았다. 그것은 중복 질문입니다. – Murillo