If two strings are equal, use isequaltostring: instead of just comparing the pointer values of the strings. For example:
Nsstring * thing1 = @ "Hello 5"; <br/> nsstring * thing2; <br/> thing2 = [nsstring stringwithformat: @ "Hello @ D", 5]; <br/> If ([thing1 isw.tostring: thing2]) {<br/> nslog (@ "they are the same! ") <Br/>}
And
If (thing1 = thing2) {<br/> nslog (@ "they are the same! ") <Br/>}
Is different.
This is because the = Operator only judges the pointer values of thing1 and thing2, rather than the objects they refer. Because thing1 and thing2 are different strings, the second comparison method considers them different.
Sometimes we want to check whether thing1 and thing2 are the same objects? In this case, the operator = should be used. If you want to check the equivalence (that is, whether these two strings represent the same thing), use isw.tostring :.