I’m pretty new to this – I’m trying to compare a NSString stringWithFormat with some text. It works fine with stringWithString. I can’t work out why it doesn’t work with stringWithFormat?
Many thanks for any help anyone can offer!
NSString *theQuestion = [NSString stringWithFormat:@"The same thing"];
if (theQuestion == @"The same thing"){
NSLog(@"stringWithFormat is the same as the given text");
}else{
NSLog(@"stringWithFormat is NOT the same as the given text");
NSLog(@"but theQuestion is:\"%@\"", theQuestion);
}
==is a reference equal. to do a string compare it has to be the