-(NSComparisonResult)caseInsensitiveCompare:(NSString *)string;
Returns the result of invoking compare:options: with NSCaseInsensitiveSearch as the only option.
NSString *myString1=@"HELLO WORLD"; NSString *myString2=@"hello world"; if([myString1 caseInsensitiveCompare:myString2]==NSOrderedSame){ NSLog(@"similar"); } else{ NSLog(@"dissimilar"); } /* defintion NSComparisonResult: enum _NSComparisonResult {NSOrderedAscending = -1, NSOrderedSame, NSOrderedDescending}; typedef NSInteger NSComparisonResult; therefore, the comparative work with numerical values */ if([myString1 caseInsensitiveCompare:myString2]==0){ NSLog(@"similar"); } else{ NSLog(@"dissimilar"); }
2012-04-15 13:15:33.835 FoundationNSString[795:403] similar 2012-04-15 13:15:33.839 FoundationNSString[795:403] similar