Re: case-insensitive strings
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.