I have a table with few columns...And I want to sort it, this is the way how I do that:
NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"column1"
ascending:NO];
But if column1 value is 0 everywhere, I want to sort it by another column...@"column2". So how init my sortDescriptor with 2 keys ? thanks
You don't have to init with two keys. You have to init two sort descriptors. Then add them to an array and then pass that array with sort descriptors to sorting method.
update
NSSortDescriptor *col1SD = [NSSortDescriptor sortDescriptorWithKey:@"column1" ascending:NO];
NSSortDescriptor *col2SD = [NSSortDescriptor sortDescriptorWithKey:@"column2" ascending:NO];
[someMutableArray sortUsingDescriptors:@[col1SD, col2SD]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With