objective c - isEqualToString vs == -


i'm new objective c (and c) , got baffled on comparison tonight.

the code located in fast enumeration loop, variables being n , w.

the broken code piece was

if (n == w) 

and fixing

if ([n isequaltostring:w]) 

i understand why second works, in fact comparing 2 strings, , logical method use (just took me while find it!) however, don't understand why first '==' comparison doesn't work, can explain in little detail me can't find references how works.

many thanks,

== compares pointers (the addresses strings) isequaltostring compares contents of strings. regardless of whether strings same objects, if identical return yes.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -