Skip to content

November 2, 2014

Compare Two Strings in Objective C

by noise

Next example shows how to compare two strings in Objective C. For that purpose we’ll use isEqualTo method.

NSString *aString = @"aaa";
NSString *anotherString = @"aaa";
 
if ( [aString isEqualTo:anotherString] ) {
     NSLog(@"Strings are equal");
} else {
     NSLog(@"Strings are not equal");
}
Read more from Objective C Tips

Leave a Reply

required
required

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments