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: Peter Ammon <email@hidden>
- Date: Wed, 13 Feb 2008 17:45:39 -0800
On Feb 13, 2008, at 12:51 PM, Daniel Child wrote:
Hi,
I am trying to work around the fact that you cannot pass parameter
values with a selector. Here's what I'm trying to do.
I have a generic table (essentially a class with an array instance
variable) filled with generic records (also a class containing an
array instance variable). I want to be able to sort the table based
on one of the fields in the generic record. Since the generic table
holds an array of records, my instinct is to use sortUsingSelector:
(SEL) s. The problem, of course, is that to set up compare methods,
I need to know which field I'm sorting on, and that is only
determined at runtime.
The NSSortDescriptor approach is fine. Another one is to use
sortedArrayUsingFunction:context: which allows you to pass a context
pointer which is received by the comparing function.
-Peter
_______________________________________________
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