So I have been trying to compare two NSStrings in xcode. However, it is not working. What am I doing wrong?
NSString Prog are characters that are xml parsed from mysql
char *cStr = "YES";
NSString *str3 = [NSString stringWithUTF8String:cStr];
if ([str3 isEqualToString:prog]) {
[switch1 setOn:YES animated:YES];
}
else {
[switch1 setOn:NO animated:YES];
}
-[NSString isEqualToString:]is normally what you would use, and what you are using in such a scenario. Ensure thatprogis a validNSString(e.g. the correct type and notnil), and keep in mind that string comparison in this implementation is case-sensitive — i.e."Yes"would not be equal to"YES".