简体   繁体   中英

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.

lyricsId and arelease.trackId are (I presume) of type 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:将比较一个字符串是否等于另一个字符串。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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