Sorting ABPerson array with NSSortDescriptors
Sorting ABPerson array with NSSortDescriptors
- Subject: Sorting ABPerson array with NSSortDescriptors
- From: Derrick Bass <email@hidden>
- Date: Wed, 28 Jun 2006 09:29:42 -0500
I'd like to sort an array of ABPersons using "uniqueId" as a key (*)
using sortedArrayUsingDescriptors, but it's not working: the returned
array has the same order as the input array. KVC seems to be working,
since I can take an ABPerson and get the ID with
valueForKey:@"uniqueId". Here's some simple test code:
NSArray *p = [[ABAddressBook sharedAddressBook] people];
NSSortDescriptor *sd = [[[NSSortDescriptor alloc]
initWithKey:@"uniqueId" ascending:YES] autorelease];
NSArray *sda = [NSArray arrayWithObject:sd];
NSArray *ps = [p sortedArrayUsingDescriptors:sda];
Any ideas why it doesn't work?
For now, I've rewritten my code to use sortedArrayUsingSelector: with
a category method for the comparison selector, but at some point I
may put these ABPersons in a user-sortable table, so I'd like to
figure out why NSSortDescriptors aren't working.
Derrick
(*) I lied. I'm really sorting by (last name, first name) using
methods in a category on ABPerson, but to avoid confusing the issue,
I tried with uniqueId and that doesn't work either. My "lastName" and
"firstName" methods never get called during the sort; I presume the
same is true of uniqueId.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden