Reputation: 1527
I just found out a bug. Tracing the bug, I saw that this is violated when A (and hence B) is nil.
I just want to make sure I am not missing anything here.
Is the answer of the question true or do I just find an exception?
Upvotes: 0
Views: 87
Reputation: 7493
In Objective-c you can send a message to a nil object ie [A isEqual:B] when A is nil. But you can't expect a nil object to return a result! I haven't yet found the Apple ref, but I suspect that the return value is either undefined or set to nil/false/0 itself.
Upvotes: 1
Reputation: 9543
The return code from a message sent to nil
will always be 0, which equates to NO
or false. So the behaviour you observe is expected and correct, even if it may not seem exactly intuitive. Different nil
objects aren't properly equal, since nil
doesn't really have an identity.
Upvotes: 3