iphone - 如何建立二级 NSSortDescriptor 排序键?

标签 iphone objective-c ios xcode4.2 nssortdescriptor

我已经通过排序键 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/

相关文章:

iOS Youtube API 列表视频

iphone - UIActivityIndi​​catorView 或类似的

iphone - 多次保存大型 nsstring 文件会使应用程序崩溃

ios - 快速添加子项目

c++ - 将 C++ 代码桥接到我的 swift 代码中。 XCode 中哪种文件扩展名适用于哪种基于 c 的语言?

ios - UIWebView 中 pdf 的可点击区域

ios - 以编程方式停止向 iPhone 发送短信

ios - 仅删除一个单元格的分隔线

objective-c - 实例变量的目的是什么?

ios - "pod install"命令在 Mac OS X 上有什么作用?