My string comparison keeps returning false and I dont understand why. Even my nslog says the value is correct. Do you know why my comparison keeps returning false even though the strings appear to be the same? If I step through the program type shows SV as its value. I have ensured there are no spaces in this string as well. We get the first two chars of this:
SV2B799E5B-4306-4965-B5DD-944D3970E6B6
NSString *fPath = [path stringByAppendingPathComponent:[directoryContent objectAtIndex:x]];
NSString *fName = [directoryContent objectAtIndex:x];
NSString *type = [fName substringToIndex:2];
NSLog(@"TYPE: %@",type);
if ([type caseInsensitiveCompare:@"SV"])
{
NSData *file = [[NSData alloc] initWithContentsOfFile:fPath];
if (file)
{
[[WebService sharedWebService]saveVolunteer:nil :YES :[directoryContent objectAtIndex:x] :file];
[file release];
}
}
[NSString -caseInsensitiveCompare:]does not return aBOOL, it returns anNSComparisonResult. This is going to be 0 if the strings are equal (in a case insensitive fashion), which is why you’re seeing that result.Invert your result and you’ll be set, or to be more correct, check to see if it is ==
NSOrderedSame.