• 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: case-insensitive strings - It's already in NSString!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: case-insensitive strings - It's already in NSString!


  • Subject: Re: case-insensitive strings - It's already in NSString!
  • From: Phillip Hutchings <email@hidden>
  • Date: Fri, 11 Oct 2002 10:38:00 +1300

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Friday, Oct 11, 2002, at 05:48 Pacific/Auckland, Matt Neuburg wrote:

On Mon, 7 Oct 2002 10:32:22 -0700, I <email@hidden> said:

I'd like to have a kind of NSString where isEqual: is case-insensitive. The
reason I want this...

[snip]

Is there an elegant and safe way to do this? You'd think there would be a
way to tell an individual string to flip case sensitivity off for the
purpose of all comparisons, but there doesn't seem to be one built in

I didn't get any useful answers. The thing that amazes me is that no one
chimed in with outraged cries of how the NSString model is inadequate.
Doesn't this bother anyone else out there besides me? This thing is an
object; the whole point of having an object is that the knowledge of how to
do stuff, such as decide whether two instance are "equal", should be made
to reside in the object. The idea that you can't flip case sensitivity on
or off for an individual string instance is just nutty to me. The idea of
having to do case-insensitive comparison "from the outside" makes me barf.
The idea of having to do it by making both comparands uppercase makes me
barf twice. I do it, but I also do a lot of barfing. m.

*sigh*

use compare: options: NSCaseInsensitiveSearch
eg
NSString *myString = @"test";
NSString *otherString = @"TEST";
NSComparisonResult *myResult = [myString compare:otherString options:NSCaseInsensitiveSearch];

or you can use:
NSComparisonResult *myResult = [myString caseInsensitiveCompare:otherString];

It's right there in the comparing section of the NSString documentation.

Phillip Hutchings
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (Darwin)

iEYEARECAAYFAj2l80AACgkQ1PJqI21cmKAqUQCcCCfPDyHBJ3wjCXMrls15YTM6
3V0An0POQeFokyhUN8eHlTfejjiP059l
=ZDDd
-----END PGP SIGNATURE-----
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: case-insensitive strings - It's already in NSString!
      • From: matt neuburg <email@hidden>
References: 
 >Re: case-insensitive strings (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: why mouseMoved doesn't work...
  • Next by Date: NSMutableArray and releases etc
  • Previous by thread: Re: case-insensitive strings
  • Next by thread: Re: case-insensitive strings - It's already in NSString!
  • Index(es):
    • Date
    • Thread