isEqualToString不能正常工作?

μ4ρ*_*κ05 2 objective-c nsstring ios

好吧,我以前做过这个,很容易,但由于某种原因我不明白为什么以下两个字符串不相等!有任何想法吗?我确信这将是一件非常容易的事情,我没有看到:

NSString *texture1name = [NSString stringWithFormat:@"world%d?nGameScrollBackground1", 0];

NSLog(@"IS EQUAL: %d", [@"world0InGameScrollBackground1" isEqualToString:texture1name]);
NSLog(@"This: %@ equal to: %@", texture1name, @"world0InGameScrollBackground1");
Run Code Online (Sandbox Code Playgroud)

当我运行上面的代码时,我得到一个:

IS EQUAL: 0
This: world0?nGameScrollBackground1 equal to: world0InGameScrollBackground1

它完全相同的字符串,没有空格或任何东西!请帮忙,谢谢!

Tyl*_*ler 8

不知怎的,你的格式字符串中有希腊字母iota@"world%d?nGameScrollBackground1"代替大写的"i",导致字符串不匹配.只需使用"我"字符重新键入格式字符串,你应该很高兴.或者只是复制粘贴:

[NSString stringWithFormat:@"world%dInGameScrollBackground1", 0];