• 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
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: case-insensitive strings


  • Subject: Re: case-insensitive strings
  • From: Andy Lee <email@hidden>
  • Date: Thu, 10 Oct 2002 15:26:38 -0400

Oops, of course I realized I had a bug the second after I hit "Send".

Here's a correction:

// (still) completely untested code:

- (NSArray *)keysForCaseInsensitiveString:(NSString *)aString
inDictionary:(NSDictionary *)aDictionary
{
NSMutableArray *resultKeys = [NSMutableArray array];
NSEnumerator *keyEnum = [aDictionary keyEnumerator];
id key;

while ((key = [keyEnum nextObject]))
{
id value = [aDictionary objectForKey:key];

if ([value isKindOfClass:[NSString class]])
{
if ([value caseInsensitiveCompare:aString] == NSOrderedSame)
{
[resultKeys addObject:key];
}
}
}

return resultKeys; // convert to an immutable NSArray first if you like
}

--Andy
_______________________________________________
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.

  • Prev by Date: is protected broken, or am I?
  • Next by Date: Help - Newbie Drag And Drop Question (again)
  • Previous by thread: Re: case-insensitive strings - It's already in NSString!
  • Next by thread: Re: case-insensitive strings
  • Index(es):
    • Date
    • Thread