From 9ee45b354dc5eb3b088e9bb2baf37a579e1100b6 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Sun, 28 Apr 2019 23:06:23 +1200 Subject: [PATCH] Fix equality check for iOS --- Source/LayoutConstraint.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/LayoutConstraint.swift b/Source/LayoutConstraint.swift index 9abb45f..bf8ef3f 100644 --- a/Source/LayoutConstraint.swift +++ b/Source/LayoutConstraint.swift @@ -44,6 +44,7 @@ public class LayoutConstraint : NSLayoutConstraint { } internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool { + #if os(OSX) // ensure first anchor items match guard let item1 = lhs.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 { 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 guard lhs.firstAttribute == rhs.firstAttribute &&