• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSString: localizedCaseInsensitiveCompare + NSNumericSearch?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString: localizedCaseInsensitiveCompare + NSNumericSearch?


  • Subject: Re: NSString: localizedCaseInsensitiveCompare + NSNumericSearch?
  • From: Aki Inoue <email@hidden>
  • Date: Tue, 21 Mar 2006 22:36:38 -0800

Jim,

return [string1 compare: string2 options: (NSCaseInsensitiveSearch | NSNumericSearch) range: NSMakeRange(0, [string1 length]) locale: locale];
That's the correct expression.

We have a plan to introduce a set of new APIs in CFString/NSString that take CFLocale/NSLocale instead of the current kCFCompareLocalized/NSDictionary-based locale approaches in a future release.

Aki

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

_______________________________________________ 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
References: 
 >NSString: localizedCaseInsensitiveCompare + NSNumericSearch? (From: Jim Correia <email@hidden>)

  • Prev by Date: Re: Doesn't -sortedArrayUsingDescriptors: use KVC accessors?
  • Next by Date: Re: Doesn't -sortedArrayUsingDescriptors: use KVC accessors?
  • Previous by thread: NSString: localizedCaseInsensitiveCompare + NSNumericSearch?
  • Next by thread: How to create paginated PDF Data from NSView without using NSPrintOperation.
  • Index(es):
    • Date
    • Thread