caseInsensitiveCompare method compares two NSString objects case-insensitively. Following example shows how to use caseInsensitiveCompare method with two NSStrings; @"Abc" and "aBC". The result should be "YES" since the two strings are the same in caseInsensitiveCompare.
#import "MyObject.h"
@implementation MyObject
- (IBAction)myAction:(id)sender
{
NSString *str1 = [NSString stringWithString:@"Abc"];
NSString *str2 = [NSString stringWithString:@"aBC"];
if ([str1 caseInsensitiveCompare:str2] == NSOrderedSame)
{
NSLog(@"YES");
}
else
{
NSLog(@"NO");
}
}
@end