Created
August 24, 2013 11:13
-
-
Save PavelGnatyuk/6327541 to your computer and use it in GitHub Desktop.
Compare objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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