I have an array of strings. The array was created by parsing a long comma delimited string into several component strings. I can NSLog those components and they appear correctly. However if I test one of those components for the very object the NSLog shows it as containing, the test still fails:
NSArray*parseLine=[[NSArray alloc] initWithArray:[newline componentsSeparatedByString:@","]];
NSLog(@"*%@*"[parseLine objectAtIndex:1]);
Output:
*N/A*
So clearly “N/A” is there, those three characters exactly.
However, this fails the test:
if ([parseLine objectAtIndex:1]==@"N/A") //never passes
Also tried this:
if ((NSString*)[parseLine objectAtIndex:1]==@"N/A")
Why doesn’t it pass the test?
==refers to address pointer as well as string.To check for equality try
isEqualToStringfunctionSo that will be
if([parseLine objectAtIndex:1] isEqualToString:@"N/A"])