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: Daniel Child <email@hidden>
- Date: Wed, 13 Feb 2008 20:36:19 -0500
I'm sorry, but looking at the documentation I don't see how using
NSSortDescriptor works. Their example uses keys for the instances of
a custom class (employee age / hire date, etc.). All I have is a
generic class. The structure of a GenericRecord is
@interface GenericRecord : NSObject
{
NSMutableArray *record;
int numFields;
}
and the fields are inside of the record ivar. My GenericTable class
contains an instance variable "records" (an array) that holds a
collection of these generic records. As far as I can tell, KVC
doesn't apply. TI am not trying to sort the records by "numFields" or
by "record" (for which I could use KVC). I want to sort them
according to field i within the record.
My comparison method should be something like this:
- (NSComparisonResult) compareRecord: (GenericRecord *) gr byField:
(int) fieldNumber;
By definition, this kind of method has arguments and cannot go be
passed as a selector. (OR CAN IT?)
As they say at the end of the chapter, "Each object in the collection
must be key-value coding-compliant for the property key used to
create the sort descriptor ." And it needs to use a compare: method
which, if specified, also employs a selector. I'm left with the same
problem I had before: no way to compare on a particular index of the
array.... If I've missed something, please let me know. Thanks.
On Feb 13, 2008, at 5:12 PM, Hamish Allan wrote:
On Feb 13, 2008 8:51 PM, Daniel Child <email@hidden> wrote:
Is there a way around this?
Use an NSSortDescriptor (you can specify the sort key, the sort
direction and the comparison selector separately).
Best wishes,
Hamish
_______________________________________________
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