Skip to content

Commit

Permalink
Fix equality check for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
robertjpayne committed Apr 28, 2019
1 parent c904582 commit 9ee45b3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Source/LayoutConstraint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 &&
Expand Down

0 comments on commit 9ee45b3

Please sign in to comment.