Equatable on NSObject

I know that this question is probably on the edge of what is proper to discuss here since it deals a tiny bit with UIKit, but since the issue boils down to how NSObject Equatable conformance is implemented I will ask the question here anyways:

In the documentation for UIImage it is stated that two UIImage instances should be compared using isEqual(_:) instead of 'directly' using ==.


But my understanding of Equatable conformance on NSObject subclasses is that == just calls isEqual(_:).
Is that no so?

You're correct. The documentation guideline about using isEqual(_:) rather than == applies in Objective-C, where == always compares object identity (like Swift's ===). Mind filing a documentation bug at https://bugreport.apple.com ?

1 Like

Thanks for clarifying! Certainly, bug is filed as https://bugreport.apple.com/web/?problemID=40373422.


And here's an OpenRadar version of the same bug report:


This is very strange behavior. Ns Object is not equatable by default if it implements just '===' under the hood.

Terms of Service

Privacy Policy

Cookie Policy