开发者

How to compare 2 string variables

开发者 https://www.devze.com 2023-01-10 19:37 出处:网络
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)

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

精彩评论

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