I don't know of any built-in way to do this. However, it would be trivial to write a category on NSArray which does this:
@interface NSArray (CaseInsensitiveIndexing)
- (NSUInteger)indexOfCaseInsensitiveString:(NSString *)aString;
@end
@implementation NSArray (CaseInsensitiveIndexing)
- (NSUInteger)indexOfCaseInsensitiveString:(NSString *)aString {
NSUInteger index = 0;
for (NSString *object in self) {
if ([object caseInsensitiveCompare:aString] == NSOrderedSame) {
return index;
}
index++;
}
return NSNotFound;
}
@end
Of course, you'd probably want to do a bit of type checking to make sure the array's items actually are NSStrings before you call -caseInsensitiveCompare:
, but you get the idea.