7
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.

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
Madan Mohan
  • 8,764
  • 17
  • 62
  • 96

2 Answers2

11

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.

Marcelo Cantos
  • 181,030
  • 38
  • 327
  • 365
5

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

mxg
  • 20,946
  • 12
  • 59
  • 80