objective c - Sort the Main NSArray using the SubArray key value pair -
I want to sort my main array based on first_name in swap self.contacts
The code that is used to sort the array
- (zero) Sort {NSSortDescriptor * sdName = [[NSSortDescriptor alloc] InitWithKey: @ "first_name" ascending: yes]; Self.contacts = [NSMutableArray arrayWithArray: [Contacted with your own word descriptor: [NSArray arrayWithObjects: sdName, zero]]]; } MyData
self.contacts = ({contact = {"first_name" = "test r";}; "Last_met" = ({"last_met_date" = "2014-10-09";});}, {contact = {"first_name" = "test of";}; "last_met" = ({"last_met_date" = "2014 -10-09 ";}};})
Try with this sort descriptor Do:
Descriptor = [[NSSSort Descriptor Alok] initWithKey: @ "contact.first_name" ascending: Yes]; parameter key is actually a key path , and nsDictionary is compliant as you like stuff You can write: [Contact [0] valueForKeyPath: @ "contact.first_name"] .
Comments
Post a Comment