0

After importing the DGElasticPullToRefresh Lib via Pods my compiler crashes. It's caused by this function of the DGElasticPullToRefreshView.swift:

 override open func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
    if keyPath == DGElasticPullToRefreshConstants.KeyPaths.ContentOffset {
        if let newContentOffset = change?[NSKeyValueChangeKey.newKey], let scrollView = scrollView() {
            let newContentOffsetY = (newContentOffset as AnyObject).cgPointValue.y
            if state.isAnyOf([.loading, .animatingToStopped]) && newContentOffsetY < -scrollView.contentInset.top {
                scrollView.contentOffset.y = -scrollView.contentInset.top
            } else {
                scrollViewDidChangeContentOffset(dragging: scrollView.isDragging)
            }
            layoutSubviews()
        }
    } else if keyPath == DGElasticPullToRefreshConstants.KeyPaths.ContentInset {
        if let newContentInset = change?[NSKeyValueChangeKey.newKey] {
            let newContentInsetTop = (newContentInset as AnyObject).uiEdgeInsetsValue.top
            originalContentInsetTop = newContentInsetTop
        }
    } else if keyPath == DGElasticPullToRefreshConstants.KeyPaths.Frame {
        layoutSubviews()
    } else if keyPath == DGElasticPullToRefreshConstants.KeyPaths.PanGestureRecognizerState {
        if let gestureState = scrollView()?.panGestureRecognizer.state, gestureState.dg_isAnyOf([.ended, .cancelled, .failed]) {
            scrollViewDidChangeContentOffset(dragging: false)
        }
    }
}

According to this post: https://stackoverflow.com/a/41043678/6003494 i could identify the row that's causing the error. It's this line in the second if clause:

let newContentInsetTop = (newContentInset as AnyObject).uiEdgeInsetsValue.top

Anyone an idea how to fix this? Thanks.

Marco Weber
  • 829
  • 10
  • 19

1 Answers1

0

I Could fix it after 2 hours of testing: I had to chance the typecast to NSValue:

From this:

let newContentInsetTop = (newContentInset as AnyObject).uiEdgeInsetsValue.top

to this:

let newContentInsetTop = (newContentInset as! NSValue).uiEdgeInsetsValue.top
Marco Weber
  • 829
  • 10
  • 19