I'm trying to figure out when I should use === to compare UIViews. I realized I've been using == without really thinking about how UIView is a reference type. But it's never caused me any problems, so it appears that === is never needed for UIViews?
My understanding of value compare ==, and identity compare ===, based on this previous question is that for classes you need to use === to know if you have the same instance, and == to know if they have the same value. However for the UIView class, == seems to work exactly like the === operator.
let v1 = UIView()
let v2 = UIView()
XCTAssertTrue(v1 === v1)
XCTAssertTrue(v1 == v1)
XCTAssertTrue(v1.isEqual(v1))
XCTAssertFalse(v1 === v2)
XCTAssertTrue(v1 == v2)
XCTAssertTrue(v1.isEqual(v2))
Based on that understanding I expect these all to pass. To know if v1 and v2 are different instances I should use ===, and == should be true since they have the same property values. However that is not what happened.
The == and === were both false. Shouldn't these work differently? These views have the same property values.
Does UIView use === to implement Equatable? Is there no reason to ever use === on UIViews?