Ios 如何对一组密钥进行排序?
我有一个Ios 如何对一组密钥进行排序?,ios,objective-c,cocoa-touch,sorting,nsarray,Ios,Objective C,Cocoa Touch,Sorting,Nsarray,我有一个nsdirectory中的NSArray密钥,如下所示: NSArray *array = [[NSArray alloc] initWithArray:[myDict allKeys]]; [array sortedArrayUsingSelector:@selector(compare:)]; 为什么阵列没有被订购?嘿,试试这个 NSSortDescriptor *lastNameSorter = [[NSSortDescriptor alloc] initWithKey:@"la
nsdirectory
中的NSArray
密钥,如下所示:
NSArray *array = [[NSArray alloc] initWithArray:[myDict allKeys]];
[array sortedArrayUsingSelector:@selector(compare:)];
为什么阵列没有被订购?嘿,试试这个
NSSortDescriptor *lastNameSorter = [[NSSortDescriptor alloc] initWithKey:@"lastName" ascending:YES];
因此,在使用数据创建NSMutablearray时,我是将其放在data.h/m文件中,还是在需要在表中显示数据时放在viewcontroller.h/m文件中?Heyy尝试一下
NSSortDescriptor *lastNameSorter = [[NSSortDescriptor alloc] initWithKey:@"lastName" ascending:YES];
因此,在使用数据创建NSMutablearray时,我是将其放在data.h/m文件中,还是在需要在表中显示数据时放在viewcontroller.h/m文件中?这可能会有帮助:
NSSortDescriptor *sortDesc = [[NSSortDescriptor alloc] initWithKey:@”self” ascending:YES];
[array sortUsingDescriptors:[NSArray arrayWithObject:sortDesc]];
[sortDesc release];
有关更多信息,请查看
NSSortDescriptor *sortDesc = [[NSSortDescriptor alloc] initWithKey:@”self” ascending:YES];
[array sortUsingDescriptors:[NSArray arrayWithObject:sortDesc]];
[sortDesc release];
有关更多信息,请查看
我认为它对你有用
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;
拉加德斯,
CNSivakUmar我认为它对你有用
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;
拉加德斯,
CNSivakUmar不起作用。。。[\uu NSArrayI sortUsingDescriptors:]:发送到实例0x6A58BC0的无法识别的选择器不起作用。。。[\uu NSArrayI sortUsingDescriptors:]:发送到实例0x6a58bc0的选择器无法识别