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 {
|
||||
#if os(OSX)
|
||||
// ensure first anchor items match
|
||||
guard let item1 = lhs.firstAnchor.item,
|
||||
let item2 = rhs.firstAnchor.item,
|
||||
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
|
||||
// If firstItem or secondItem on either constraint has a dangling pointer
|
||||
// this comparison can cause a crash. The solution for this is to ensure
|
||||
// your layout code hold strong references to things like Views, LayoutGuides
|
||||
// and LayoutAnchors as SnapKit will not keep strong references to any of these.
|
||||
guard lhs.firstAttribute == rhs.firstAttribute &&
|
||||
lhs.secondAttribute == rhs.secondAttribute &&
|
||||
lhs.relation == rhs.relation &&
|
||||
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 true
|
||||
|
|
Loading…
Reference in New Issue