Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSSortDescriptor not working with array of custom classes



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.