我有一个来自NSArray
的{{1}}个密钥:
NSDictionary
为什么不对数组进行排序?
答案 0 :(得分:3)
我认为它对你有用
NSDictionary *stateZip;
NSArray *states;
NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
self.stateZip=dictionary;
[dictionary release];
NSArray *component = [self.stateZip allKeys];
NSArray *sorted =[component sortedArrayUsingSelector:@selector(compare:)];
self.states=sorted;
ragards, CNSivakUmar
答案 1 :(得分:0)
Heyy试试这个....
NSSortDescriptor *lastNameSorter = [[NSSortDescriptor alloc] initWithKey:@"lastName" ascending:YES];
所以我把它放在data.h / m文件中,因为NSMutablearray是用数据创建的,或者是在viewcontroller.h / m文件中,因为我需要在表中显示数据?
答案 2 :(得分:0)
这可能会有所帮助:
NSSortDescriptor *sortDesc = [[NSSortDescriptor alloc] initWithKey:@”self” ascending:YES];
[array sortUsingDescriptors:[NSArray arrayWithObject:sortDesc]];
[sortDesc release];
有关详细信息,请查看