Skip to content

Commit e580b4c

Browse files
committed
Safe
1 parent c63c0b5 commit e580b4c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

StackScrollView/StackScrollViewCellType.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,23 @@ public protocol StackScrollViewCellType: class {
2828

2929
extension StackScrollViewCellType where Self: UIView {
3030

31-
public var stackScrollView: StackScrollView {
31+
public var stackScrollView: StackScrollView? {
3232
var superview: UIView? = self
3333

3434
while !(superview is StackScrollView) {
3535
superview = superview?.superview
3636
}
3737

38-
precondition(superview is StackScrollView, "Must be added StackScrollView")
39-
return superview as! StackScrollView
38+
return superview as? StackScrollView
4039
}
4140

4241
public func scrollToSelf(animated: Bool) {
4342

44-
stackScrollView.scroll(to: self, animated: animated)
43+
stackScrollView?.scroll(to: self, animated: animated)
4544
}
4645

4746
public func updateLayout(animated: Bool) {
4847
invalidateIntrinsicContentSize()
49-
stackScrollView.updateLayout(animated: animated)
48+
stackScrollView?.updateLayout(animated: animated)
5049
}
5150
}

0 commit comments

Comments
 (0)