• 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
NSSortDescriptor not working with array of custom classes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSSortDescriptor not working with array of custom classes


  • Subject: NSSortDescriptor not working with array of custom classes
  • From: Ken Tozier <email@hidden>
  • Date: Fri, 19 Oct 2007 12:33:33 -0400

Hi

I have an NSMutableArray containing instances of a custom "Page" class and can't get NSSortDescriptor to do anything. The page class has an accessor method for the property I want to sort.

- (id) pageNumber
{
	return [pageRecord objectForKey: @"page_number"];
}

In the object that contains the page array, the sort descriptor array is initialized like this

NSArray *sortDescriptors = [NSArray arrayWithObject: [[NSSortDescriptor alloc] initWithKey: @"pageNumber" ascending: YES]];

And I try to use it like this

NSLog(@"before sorting: %@", selectedPages);

[selectedPages sortUsingDescriptors: sortDescriptors];

NSLog(@"after sorting: %@", selectedPages);

Regardless of the order in which I select pages, the before and after arrays are identical. Anyone see where I'm messing up?

Thanks for any help

Ken
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSSortDescriptor not working with array of custom classes
      • From: Ken Tozier <email@hidden>
  • Prev by Date: Re: Ignored exceptions...
  • Next by Date: Re: Mulit-state buttons
  • Previous by thread: Cocoa developers required for an interesting contract in Belgium
  • Next by thread: Re: NSSortDescriptor not working with array of custom classes
  • Index(es):
    • Date
    • Thread