Search code examples
objective-cstringstring-comparison

Case insensitive compare strings in Objective-C


I want to compare 2 strings. I am doing it like this:

[someString isEqualToString:otherString];

But I have the problem that when there are capital letters but the words are the same I don't get a YES as result.


Solution

  • if( [@"Some String" caseInsensitiveCompare:@"some string"] == NSOrderedSame ) {
      // strings are equal except for possibly case
    }