User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







objective-c:foundation.framework:nsstring.h:caseinsensitivecompare
click
to support this page (eg 0,42 € or so) Thanks.

caseInsensitiveCompare

    -(NSComparisonResult)caseInsensitiveCompare:(NSString *)string;  

Returns the result of invoking compare:options: with NSCaseInsensitiveSearch as the only option.

ObjC Sourcecode Example

    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");    
        }
 

Output for this example code

2012-04-15 13:15:33.835 FoundationNSString[795:403] similar
2012-04-15 13:15:33.839 FoundationNSString[795:403] similar
advertising
objective-c/foundation.framework/nsstring.h/caseinsensitivecompare.txt · Last modified: 2012/12/20 12:24 (external edit)

Impressum