• 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
NSString: localizedCaseInsensitiveCompare + NSNumericSearch?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSString: localizedCaseInsensitiveCompare + NSNumericSearch?
      • From: Aki Inoue <email@hidden>
  • Prev by Date: Re: -[NSString localizedCompare:] - example of semantic difference with compare?
  • Next by Date: How to create paginated PDF Data from NSView without using NSPrintOperation.
  • Previous by thread: Re: -[NSString localizedCompare:] - example of semantic difference with compare?
  • Next by thread: Re: NSString: localizedCaseInsensitiveCompare + NSNumericSearch?
  • Index(es):
    • Date
    • Thread