Fix equality check for iOS

This commit is contained in:
Robert Payne 2019-04-28 23:06:23 +12:00
parent c904582015
commit 9ee45b354d
1 changed files with 11 additions and 0 deletions

View File

@ -44,6 +44,7 @@ public class LayoutConstraint : NSLayoutConstraint {
} }
internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool { internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool {
#if os(OSX)
// ensure first anchor items match // ensure first anchor items match
guard let item1 = lhs.firstAnchor.item, guard let item1 = lhs.firstAnchor.item,
let item2 = rhs.firstAnchor.item, let item2 = rhs.firstAnchor.item,
@ -56,6 +57,16 @@ internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool {
(lhs.secondAnchor?.item === rhs.secondAnchor?.item)) else { (lhs.secondAnchor?.item === rhs.secondAnchor?.item)) else {
return false return false
} }
#else
guard lhs.firstAnchor == rhs.firstAnchor else {
return false
}
guard ((lhs.secondAnchor == nil && rhs.secondAnchor == nil) ||
(lhs.secondAnchor! == rhs.secondAnchor!)) else {
return false
}
#endif
// ensure attributes, relation, priorty and multiplier match // ensure attributes, relation, priorty and multiplier match
guard lhs.firstAttribute == rhs.firstAttribute && guard lhs.firstAttribute == rhs.firstAttribute &&