Repository: danielgindi/Charts
File: Source/Charts/Charts/BarLineChartViewBase.swift (Swift)

Code before:
    #if os(OSX)
    public func gestureRecognizerShouldBegin(gestureRecognizer: NSGestureRecognizer) -> Bool
    {
        return nsuiGestureRecognizerShouldBegin(gestureRecognizer)
    }
    #endif
    
    open func gestureRecognizer(_ gestureRecognizer: NSUIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: NSUIGestureRecognizer) -> Bool
    {
        #if !os(tvOS)
            if ((gestureRecognizer.isKind(of: NSUIPinchGestureRecognizer.self) &&
                otherGestureRecognizer.isKind(of: NSUIPanGestureRecognizer.self)) ||
                (gestureRecognizer.isKind(of: NSUIPanGestureRecognizer.self) &&
                    otherGestureRecognizer.isKind(of: NSUIPinchGestureRecognizer.self)))
            {
                return true
            }
        #endif
        
        if (gestureRecognizer.isKind(of: NSUIPanGestureRecognizer.self) &&
            otherGestureRecognizer.isKind(of: NSUIPanGestureRecognizer.self) && (
                gestureRecognizer == _panGestureRecognizer
            ))
        {
            var scrollView = self.superview
            while (scrollView !== nil && !(scrollView?.isKind(of: NSUIScrollView.self) ?? false))
            {
                scrollView = scrollView?.superview
            }
            
            // If there is two scrollview together, we pick the superview of the inner scrollview.
            // In the case of UITableViewWrepperView, the superview will be UITableView
            if let superViewOfScrollView = scrollView?.superview
                , superViewOfScrollView.isKind(of: NSUIScrollView.self)
            {
                scrollView = superViewOfScrollView
            }

            var foundScrollView = scrollView as? NSUIScrollView
            
            if !(foundScrollView?.nsuiIsScrollEnabled ?? true)
            {
                foundScrollView = nil
            }
            
            var scrollViewPanGestureRecognizer: NSUIGestureRecognizer!
            
            foundScrollView?.nsuiGestureRecognizers?.forEach { scrollRecognizer in
                if let panGestureRecognizer = scrollRecognizer as? NSUIPanGestureRecognizer
                {
                    scrollViewPanGestureRecognizer = panGestureRecognizer

Review comment (suggestion):
Same issue here where if the last component is evaluated and `scrollView == nil` we return `true`
Easiest way to solve this is to replace
`(scrollView !== nil && !(scrollView?.isKind(of: NSUIScrollView.self) ?? false))`
with
`!(scrollView?.isKind(of: NSUIScrollView.self) ?? true)`

Code after:
        return nsuiGestureRecognizerShouldBegin(gestureRecognizer)
    }
    #endif
    
    open func gestureRecognizer(_ gestureRecognizer: NSUIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: NSUIGestureRecognizer) -> Bool
    {
        #if !os(tvOS)
            if ((gestureRecognizer.isKind(of: NSUIPinchGestureRecognizer.self) &&
                otherGestureRecognizer.isKind(of: NSUIPanGestureRecognizer.self)) ||
                (gestureRecognizer.isKind(of: NSUIPanGestureRecognizer.self) &&
                    otherGestureRecognizer.isKind(of: NSUIPinchGestureRecognizer.self)))
            {
                return true
            }
        #endif
        
        if (gestureRecognizer.isKind(of: NSUIPanGestureRecognizer.self) &&
            otherGestureRecognizer.isKind(of: NSUIPanGestureRecognizer.self) && (
                gestureRecognizer == _panGestureRecognizer
            ))
        {
            var scrollView = self.superview
            while !(scrollView?.isKind(of: NSUIScrollView.self) ?? true)
            {
                scrollView = scrollView?.superview
            }
            
            // If there is two scrollview together, we pick the superview of the inner scrollview.
            // In the case of UITableViewWrepperView, the superview will be UITableView
            if let superViewOfScrollView = scrollView?.superview
                , superViewOfScrollView.isKind(of: NSUIScrollView.self)
            {
                scrollView = superViewOfScrollView
            }

            var foundScrollView = scrollView as? NSUIScrollView
            
            if !(foundScrollView?.nsuiIsScrollEnabled ?? true)
            {
                foundScrollView = nil
            }
            
            let scrollViewPanGestureRecognizer = foundScrollView?.nsuiGestureRecognizers?.first {
                $0 is NSUIPanGestureRecognizer
            }
            
            if otherGestureRecognizer === scrollViewPanGestureRecognizer
            {
                _outerScrollView = foundScrollView
                
                return true