NSString: localizedCaseInsensitiveCompare + NSNumericSearch?
NSString: localizedCaseInsensitiveCompare + NSNumericSearch?
- Subject: NSString: localizedCaseInsensitiveCompare + NSNumericSearch?
- From: Jim Correia <email@hidden>
- Date: Tue, 21 Mar 2006 22:49:06 -0500
I have two strings that I'd like to do a localized, case insensitive
compare where digits are compared numerically.
There doesn't appear to be a Foundation equivalent of
kCFCompareLocalized.
What is the correct way to express this in Foundation?
static int sort_func(id string1, id string2, void * context)
{
NSDictionary *locale = [[NSUserDefaults standardUserDefaults]
dictionaryRepresentation];
return [string1 compare: string2 options: (NSCaseInsensitiveSearch |
NSNumericSearch) range: NSMakeRange(0, [string1 length]) locale:
locale];
}
(I know with toll free bridging that I can use CF, but I want to know
what the objective C syntax is so I can add an appropriate category
to NSString.)
This appears to give me the same result collation order as the Finder
(using Deborah Goldsmith's advice of checking against Hawaiian.)
Thanks,
Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden