Re: how to simulate passing parameter with selector
Re: how to simulate passing parameter with selector
- Subject: Re: how to simulate passing parameter with selector
- From: Adam P Jenkins <email@hidden>
- Date: Thu, 14 Feb 2008 02:07:23 -0500
On Feb 13, 2008, at 8:36 PM, Daniel Child wrote:
I'm sorry, but looking at the documentation I don't see how using
NSSortDescriptor works.
I agree I don't think NSSortDescriptor would be useful in this case,
since you want to sort on an array index rather than on a selector.
However several people have also mentioned the
sortedArrayUsingFunction:context: method of NSArray, which will allow
you to do what you want. You'd use it something like this:
NSArray *arrayOfArrays = [create array of arrays];
int column = 2; // sort on column 2
NSInteger compare(id a, id b, void *context) {
int column = *((int*)context);
compare [a objectAtIndex:column] and [b objectAtIndex:column]
}
NSArray *sorted = [arrayOfArrays sortedArrayUsingFunction:compare
context:&column];
_______________________________________________
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