开发者

How to compare 2 string variables

Please tell me how to compare 2 string variables I'm not talking about a string variable and a string (that is already posted on this site)

I have tried this:

if (s isEqualToString: str) {
  // ...
} 

Here s and ss are two NSMutableStrings that already having values, but this isn't working. I have al开发者_Python百科so tried isEqual but failed again.

Please help


You're missing brackets.

if ([s isEqualToString:ss]) {
    // ...
}

You can't just use ==, because a string with the same content may be stored in different objects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜