Skip to content

Instantly share code, notes, and snippets.

@PavelGnatyuk
Created August 24, 2013 11:13
Show Gist options
  • Save PavelGnatyuk/6327541 to your computer and use it in GitHub Desktop.
Save PavelGnatyuk/6327541 to your computer and use it in GitHub Desktop.
Compare objects
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSString *text1 = @"String number 1.";
NSString *text2 = [NSString stringWithFormat:@"String number %i.", 1];
BOOL equal1 = (text1 == text2);
NSLog(@"pointer values are %@", equal1 ? @"equal" : @"not equal");
BOOL equal2 = [text1 isEqual:text2];
NSLog(@"objects are %@", equal2 ? @"equal" : @"not equal");
BOOL equal3 = [text1 isEqualToString:text2];
NSLog(@"string objects are %@", equal3 ? @"equal" : @"not equal");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment