开发者

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

开发者 https://www.devze.com 2022-12-25 18:10 出处:网络
if(lyricsId == areleased.trackId) { ----------; ----------; } when i am workin开发者_如何转开发g with above code it does not entered into that loop So, I used the below code,then it entered into th
if(lyricsId == areleased.trackId)

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

when i am workin开发者_如何转开发g 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.


== will compare pointers(addresses) equality, while isEqualToString:will compare if one string is equal to another.

0

精彩评论

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

关注公众号