Re: Problems with isEqualToString
Re: Problems with isEqualToString
- Subject: Re: Problems with isEqualToString
- From: Andy Lee <email@hidden>
- Date: Sat, 23 Mar 2002 14:43:37 -0500
At 11:22 AM -0800 3/23/02, Ben Mackin wrote:
resultString = [[NSString alloc]
initWithContentsOfFile:@"/tmp/errorCode"];
[[NSFileManager alloc] removeFileAtPath:@"/tmp/errorCode" handler:nil];
NSLog(@"my result code");
NSLog(resultString); //Note that right here I see it is success
if([resultString isEqualToString:@"success"]==YES)
{
When you load resultString from the text file it has a newline at the
end of it. That is why it does not match the string @"success". You
should either chop the newline off or compare resultString to
@"success\n".
Because of subtleties like this, when I print a string value for
debugging purposes, I surround it with a delimiter (usually square
brackets, out of habit). For example:
NSLog(@"my result code: [%@]", resultString);
This would have shown you something like...
my result code: [success
]
...and you would have seen there was a newline before the closing
square bracket.
--Andy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.