The ==
operator tests whether the two expressions are the same pointer to the same object. Cocoa calls this relation “identical” (see, for example, NSArray's indexOfObjectIdenticalTo:
).
To test whether two objects are equal, you would send one of them an isEqual:
message (or a more specific message, such as isEqualToString:
, if it responds to one), passing the other object. This would return YES
if you really only have one object (equal to itself, obviously) or if you have two objects that are equal. In the latter case, ==
will evaluate to NO
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…