mirror of https://github.com/SnapKit/SnapKit
Revert #574
This commit is contained in:
parent
222e14ab37
commit
1754aed4dc
|
@ -44,36 +44,17 @@ public class LayoutConstraint : NSLayoutConstraint {
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool {
|
internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool {
|
||||||
#if os(OSX)
|
// If firstItem or secondItem on either constraint has a dangling pointer
|
||||||
// ensure first anchor items match
|
// this comparison can cause a crash. The solution for this is to ensure
|
||||||
guard let item1 = lhs.firstAnchor.item,
|
// your layout code hold strong references to things like Views, LayoutGuides
|
||||||
let item2 = rhs.firstAnchor.item,
|
// and LayoutAnchors as SnapKit will not keep strong references to any of these.
|
||||||
item1 === item2 else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// ensure second anchor items match
|
|
||||||
guard ((lhs.secondAnchor?.item == nil && rhs.secondAnchor?.item == nil) ||
|
|
||||||
(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 &&
|
guard lhs.firstAttribute == rhs.firstAttribute &&
|
||||||
lhs.secondAttribute == rhs.secondAttribute &&
|
lhs.secondAttribute == rhs.secondAttribute &&
|
||||||
lhs.relation == rhs.relation &&
|
lhs.relation == rhs.relation &&
|
||||||
lhs.priority == rhs.priority &&
|
lhs.priority == rhs.priority &&
|
||||||
lhs.multiplier == rhs.multiplier else {
|
lhs.multiplier == rhs.multiplier &&
|
||||||
|
lhs.secondItem === rhs.secondItem &&
|
||||||
|
lhs.firstItem === rhs.firstItem else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue