I have an nsmutablearray named nsmarrMedicineInfo. I want to sort the element by using NSSortDescriptor. When I execute the following code it shows NSUnknownKeyException. I can not find what will be the key of the array.
NSSortDescriptor *sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"sort" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)] autorelease];
NSArray *sort = [NSArray arrayWithObject:sortDescriptor];
NSArray *sortedArray = [nsmarrMedicineInfo sortedArrayUsingDescriptors:sort];
Here key will be one of the property(key-value pair) of your custom object of array
nsmarrMedicineInfo, on which you wish to sort your array.As in apple’s doc:
But if
nsmarrMedicinInfoobject consists of strings only then you can usesortedArrayUsingSelectormethod instead ofsortDescriptor.Thanks,