简体   繁体   English

Objective C中isEqualToString和operator ==之间的差异是什么?

[英]What is the diffrence between isEqualToString and operator == in Objective C?

if(lyricsId == areleased.trackId)

{
  ----------;
  ----------;
}

when i am working with above code it does not entered into that loop So, I used the below code,then it entered into the loop and i got out put. 当我使用上面的代码它没有进入那个循环所以,我使用下面的代码,然后它进入循环,我出去了。

if([lyricsId isEqualToString:areleased.trackId])
{
    ----------;
    ----------;

}

Is there any difference between == and isEqualToString. ==和isEqualToString之间有什么区别吗?

lyricsId and arelease.trackId are (I presume) of type NSString* . lyricsIdarelease.trackId是(我推测)类型NSString* The == simply compares the pointers, which will usually be different even if their contents are the same. ==只是比较指针,即使它们的内容相同,它们通常也会不同。 The isEqualToString method compares their contents. isEqualToString方法比较它们的内容。

==将比较指针(地址)的相等性,而isEqualToString:将比较一个字符串是否等于另一个字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM