For normal data types, as long as the value equals = = will return true, for two pointer-type variables, they must point to the same pointer variable, that is, they point to the address must be equal.
Equal and using = = To determine whether two objects are equal is no different.
But sometimes when we compare strings, we can return true as long as the values are equal, because the equal method is overridden.
For this method, we can define their own conditions, and all classes inherit from the NSObject class, and we can override this method.
For string comparisons, the string also defines a isequaltostring method that is specifically used to determine the sequence of strings
One problem is most interesting to use @ "Who am I" and stringwithformat:@ "Who am I?" What's the difference between these two?
The difference is as follows:
@ "Who am I?" Using a constant pool, the constant pool guarantees that the string has a direct amount of only one, and there is no more than one copy.
NSString * S1 = @ "Who am I?";
NSString * s2 = @ "Who am I?";
Print out the address values of S1 and S2, and you can find the exact same
Using stringwithformat:@ "Who am I", this is created by the runtime, is saved in the runtime memory area (heap memory), is not placed in the constant pool, so the address and S1 S2 are different.
iOS development = = and equal differences and links