                     } else {
                         label.text = "pull to refresh"
                     }
-                    previousOffset = scrollView?.contentOffset.y
+                    previousOffset = scrollView!.contentOffset.y
                 }
             }
         } else {

                var scrollView = object as? UIScrollView
                if (scrollView != nil) {
                    println(scrollView?.contentOffset.y)
                    if (scrollView?.contentOffset.y <= -50) {
                        label.text = "release to refresh"
                        if (scrollView?.dragging == false && loading == false) {
                            loading = true


public class PullToRefreshView: UIView {
    
    var previousOffset: CGFloat = 0
    var pullToRefreshAction: (() -> ())
    var label: UILabel = UILabel()
    var activityIndicator: UIActivityIndicatorView
