NSDictionary를 정렬하려고합니다. 당신이 사용할 수있는 참조 Apple docs에서NSDictionary를 내림차순으로 내림차순으로 정렬합니다. `compare : options :`selector를 사용하여 옵션을 보내는 방법은 무엇입니까?
는 keysSortedByValueUsingSelector
: 제공
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:63], @"Mathematics",
[NSNumber numberWithInt:72], @"English",
[NSNumber numberWithInt:55], @"History",
[NSNumber numberWithInt:49], @"Geography",
nil];
NSArray *sortedKeysArray = [dict keysSortedByValueUsingSelector:@selector(compare:)];
:
// sortedKeysArray contains: Geography, History, Mathematics, English
하지만 내가 원하는 :
// sortedKeysArray contains: English, Mathematics, History, Geography
난 당신이 compare:options:
를 사용할 수 읽었습니다 및 NSStringCompareOptions
을 입력하여 계정을 변경하십시오. 다른 방향으로 비교할 수 있습니다.
그러나 선택자에서 옵션을 사용하여 compare:options:
을 보내는 방법을 이해하지 못합니다.
NSArray *sortedKeysArray = [dict keysSortedByValueUsingSelector:@selector(compare:options:NSOrderDescending)];
는 어떻게 비교의 순서를 전환해야합니다 :
나는 이런 일을하고 싶지?
관련 : https://discussions.apple.com/thread/3411089?start=0&tstart=0
'NSArray를 * ascedingArray = [[sortedKeysArray reverseObjectEnumerator] allObjects]' –