@@ -90,14 +90,14 @@ open class PullToRefresh: NSObject {
9090
9191 // MARK: KVO
9292
93- fileprivate var KVOContext = " PullToRefreshKVOContext "
93+ fileprivate static var KVOContext = " PullToRefreshKVOContext "
9494 fileprivate let contentOffsetKeyPath = " contentOffset "
9595 fileprivate let contentInsetKeyPath = " contentInset "
9696 fileprivate let contentSizeKeyPath = " contentSize "
9797 fileprivate var previousScrollViewOffset : CGPoint = CGPoint . zero
9898
9999 override open func observeValue( forKeyPath keyPath: String ? , of object: Any ? , change: [ NSKeyValueChangeKey : Any ] ? , context: UnsafeMutableRawPointer ? ) {
100- if ( context == & KVOContext && keyPath == contentOffsetKeyPath && object as? UIScrollView == scrollView) {
100+ if ( context == & PullToRefresh . KVOContext && keyPath == contentOffsetKeyPath && object as? UIScrollView == scrollView) {
101101 var offset : CGFloat
102102 switch position {
103103 case . top:
@@ -125,11 +125,11 @@ open class PullToRefresh: NSObject {
125125 }
126126 default : break
127127 }
128- } else if ( context == & KVOContext && keyPath == contentSizeKeyPath && object as? UIScrollView == scrollView) {
128+ } else if ( context == & PullToRefresh . KVOContext && keyPath == contentSizeKeyPath && object as? UIScrollView == scrollView) {
129129 if case . bottom = position {
130130 refreshView. frame = CGRect ( x: 0 , y: scrollView!. contentSize. height, width: scrollView!. bounds. width, height: refreshView. bounds. height)
131131 }
132- } else if ( context == & KVOContext && keyPath == contentInsetKeyPath && object as? UIScrollView == scrollView) {
132+ } else if ( context == & PullToRefresh . KVOContext && keyPath == contentInsetKeyPath && object as? UIScrollView == scrollView) {
133133 if self . state == . initial {
134134 scrollViewDefaultInsets = scrollView!. contentInset
135135 }
@@ -146,9 +146,9 @@ open class PullToRefresh: NSObject {
146146 return
147147 }
148148
149- scrollView. addObserver ( self , forKeyPath: contentOffsetKeyPath, options: . initial, context: & KVOContext)
150- scrollView. addObserver ( self , forKeyPath: contentSizeKeyPath, options: . initial, context: & KVOContext)
151- scrollView. addObserver ( self , forKeyPath: contentInsetKeyPath, options: . new, context: & KVOContext)
149+ scrollView. addObserver ( self , forKeyPath: contentOffsetKeyPath, options: . initial, context: & PullToRefresh . KVOContext)
150+ scrollView. addObserver ( self , forKeyPath: contentSizeKeyPath, options: . initial, context: & PullToRefresh . KVOContext)
151+ scrollView. addObserver ( self , forKeyPath: contentInsetKeyPath, options: . new, context: & PullToRefresh . KVOContext)
152152
153153 isObserving = true
154154 }
@@ -158,9 +158,9 @@ open class PullToRefresh: NSObject {
158158 return
159159 }
160160
161- scrollView. removeObserver ( self , forKeyPath: contentOffsetKeyPath, context: & KVOContext)
162- scrollView. removeObserver ( self , forKeyPath: contentSizeKeyPath, context: & KVOContext)
163- scrollView. removeObserver ( self , forKeyPath: contentInsetKeyPath, context: & KVOContext)
161+ scrollView. removeObserver ( self , forKeyPath: contentOffsetKeyPath, context: & PullToRefresh . KVOContext)
162+ scrollView. removeObserver ( self , forKeyPath: contentSizeKeyPath, context: & PullToRefresh . KVOContext)
163+ scrollView. removeObserver ( self , forKeyPath: contentInsetKeyPath, context: & PullToRefresh . KVOContext)
164164
165165 isObserving = false
166166 }
0 commit comments