我已经通过排序键 lastName
成功地对我拥有的数据进行了排序,但我想知道如何先按 lastName
排序,然后再按 firstName
。这是我用来按 lastName
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"firstName" ascending:YES];
[request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
如何添加 firstName
的辅助排序键?
最佳答案
NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@"firstName" ascending:YES];
NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor alloc] initWithKey:@"lastName" ascending:YES];
[request setSortDescriptors:[NSArray arrayWithObjects:sortDescriptor1, sortDescriptor2, nil]];
关于iphone - 如何建立二级 NSSortDescriptor 排序键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8410637/