     public override func willMoveToSuperview(newSuperview: UIView!) {
 
         superview?.removeObserver(self, forKeyPath: contentOffsetKeyPath, context: &KVOContext)
-        if (newSuperview != nil && newSuperview.isKindOfClass(UIScrollView)) {
-            newSuperview.addObserver(self, forKeyPath: contentOffsetKeyPath, options: .Initial, context: &KVOContext)
-            scrollViewBouncesDefaultValue = (newSuperview as! UIScrollView).bounces
-            scrollViewInsetsDefaultValue = (newSuperview as! UIScrollView).contentInset
+        if let scrollView = newSuperview as? UIScrollView {
+            scrollView.addObserver(self, forKeyPath: contentOffsetKeyPath, options: .Initial, context: &KVOContext)
+            scrollViewBouncesDefaultValue = scrollView.bounces
+            scrollViewInsetsDefaultValue = scrollView.contentInset
         }
     }
     

                        labelTitle.text = NSLocalizedString("Pull to refresh", comment: "Refresher")
                        animator.changeProgress(-offsetWithoutInsets / self.frame.size.height)
                    }
                    previousOffset = scrollView!.contentOffset.y
                }
            }
        } else {

        self.animator.stopAnimation()
        var scrollView = superview as! UIScrollView
        scrollView.bounces = self.scrollViewBouncesDefaultValue
        UIView.animateWithDuration(0.3, animations: {
            scrollView.contentInset = self.scrollViewInsetsDefaultValue
        }) { finished in
            self.animator.changeProgress(0)
        }
    }
