我对此很陌生——我试着比较NSCORT STRIGHF格式和一些文本。它和弦一起工作很好。我搞不懂为什么它不能和StringWithFormat一起工作?
非常感谢任何人的帮助!

    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);
    }

最佳答案

==是一个相等的引用。要比较字符串,必须是

if([theQuestion isEqualToString:@"The same thing"]){

}

10-07 19:51