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

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -