Table of Contents

isEqualToString

   - (BOOL)isEqualToString:(NSString *)aString;   

Returns a Boolean value that indicates whether a given string is equal to the receiver using an literal Unicode-based comparison.

ObjC Sourcecode Example

    NSString *myString1=@"Hello World";
    NSString *myString2=@"Hello World";
 
        if([myString1 isEqualToString:myString2]){
 
            NSLog(@"similar");
        }
        else{
 
            NSLog(@"dissimilar");
        }
 
         //  it returns a boolean, a special int
        NSLog(@"%i", [myString1 isEqualToString:myString2]);
 

Output for this example code

2012-04-15 12:47:04.266 FoundationNSString[719:403] similar
2012-04-15 12:47:04.269 FoundationNSString[719:403] 1