I want to order NSMutableArray
contain objects according to two of object property one of them has double
type second has NSString
?
I tried to use this method but I got exception :
NSString * LASTNAME = @"lastName";
NSString * GRADE = @"grade";
NSSortDescriptor *lastDescriptor =
[[NSSortDescriptor alloc]
initWithKey:LASTNAME
ascending:YES
selector:@selector(localizedCaseInsensitiveCompare:)];
NSSortDescriptor *firstDescriptor =
[[NSSortDescriptor alloc]
initWithKey:GRADE
ascending:YES
selector:@selector(localizedCaseInsensitiveCompare:)]];
NSArray * descriptors =
[NSArray arrayWithObjects:lastDescriptor, firstDescriptor, nil];
NSArray * sortedArray =
[students sortedArrayUsingDescriptors:descriptors];
@interface Student : NSObject
{
NSString * firstName;
NSString * lastName;
double grade;
}