objective c - isEqualToString vs == -
this question has answer here:
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
Post a Comment