• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Sorting ABPerson array with NSSortDescriptors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Prev by Date: Re: One of the children has a bad / missing connection
  • Next by Date: Re: Distributed Objects and Bonjour
  • Previous by thread: Re: Implementing a TCP port listener in Cocoa
  • Next by thread: Sorting ABPerson array with NSSortDescriptors
  • Index(es):
    • Date
    • Thread