如何建立辅助NSSortDescriptor排序键?

tar*_*eel 11 iphone objective-c nssortdescriptor ios xcode4.2

我已经通过我的排序键成功地对我拥有的数据进行了排序lastName,但我想知道如何排序lastName,然后依次排序firstName.这是我用来排序的代码lastName

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"firstName" ascending:YES];
[request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
Run Code Online (Sandbox Code Playgroud)

如何添加辅助排序键firstName

das*_*ght 47

NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@"firstName" ascending:YES];
NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor alloc] initWithKey:@"lastName" ascending:YES];

[request setSortDescriptors:[NSArray arrayWithObjects:sortDescriptor1, sortDescriptor2, nil]];
Run Code Online (Sandbox Code Playgroud)