FROM : Ken Thomases
DATE : Fri Jun 06 21:05:27 2008
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
DATE : Fri Jun 06 21:05:27 2008
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
| Related mails | Author | Date |
|---|---|---|
| George Stuart | Jun 6, 10:43 | |
| Ken Thomases | Jun 6, 21:05 | |
| Andrew Merenbach | Jun 6, 21:26 | |
| George Stuart | Jun 6, 23:06 | |
| Adam R. Maxwell | Jun 6, 23:16 | |
| Ken Thomases | Jun 6, 23:51 | |
| Adam R. Maxwell | Jun 7, 00:53 | |
| Kyle Sluder | Jun 9, 05:15 |






Cocoa mail archive

