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 ==.
https://developer.apple.com/documentation/uikit/uiimage
But my understanding of Equatable conformance on NSObject subclasses is that == just calls isEqual(_:).
Is that no so?
jrose
(Jordan Rose)
2
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 Feedback Assistant.
Sincerely,
/morten
2 Likes
And here's an OpenRadar version of the same bug report:
http://www.openradar.me/radar?id=4928825263652864
This is very strange behavior. Ns Object is not equatable by default if it implements just '===' under the hood.