I've run into a snag... Could someone please tell me why this doesn't work? and show me how I can make it work? thanks
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *str1 = @"abc";
NSString *str2;
str2 = [str1 substringWithRange:NSMakeRange(0,1)];
if (str2 == @"a")
printf("YES");
else
printf("NO");
[pool drain];
return 0;
}
It gives me "NO." I want to get "YES." They're both a's so I don't understand why it says they are not the same. Thanks in advance.
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *str1 = @"abc";
NSString *str2;
str2 = [str1 substringWithRange:NSMakeRange(0,1)];
if (str2 == @"a")
printf("YES");
else
printf("NO");
[pool drain];
return 0;
}
It gives me "NO." I want to get "YES." They're both a's so I don't understand why it says they are not the same. Thanks in advance.