Quoting Ken Thomases <[EMAIL PROTECTED]>:

On Jun 6, 2008, at 3:43 AM, George Stuart wrote:

NSSortDescriptor *desc = [[NSSortDescriptor alloc] initWithKey:nil ascending:NO selector:@selector(localizedCompare:)]; NSArray *sortedArray = [unsortedArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:desc]];
[desc release];

That seems to work just fine... but I'm worried. I "guessed" at using the key of "nil" since I want the actual objects in the array to be the target for the @selector. Is it a fluke that this works? I don't want to rely on undefined behavior.

Hmm.  Good question.  You could use @"description" as the key to
eliminate the uncertainty.  Or maybe @"self".

Cheers,
Ken


Hi,

This may not be an option in every case, but would making a "wrapper" class for your strings work? It'd just be a basic class with an accessor/property and a corresponding ivar that would then be the sort key.

Cheers,
Andrew
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to