User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







objective-c:foundation.framework:nsstring.h:caseinsensitivecompare

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

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
objective-c/foundation.framework/nsstring.h/caseinsensitivecompare.txt · Last modified: 2024/02/16 01:12 (external edit)

Impressum Datenschutz