         
         self.navigationItem.title = "Receipts"
         
-        tableView.rowHeight = UITableViewAutomaticDimension
-        tableView.estimatedRowHeight = 160
-        tableView.separatorInset = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0)
-        tableView.layoutMargins = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0)
+        self.tableView.rowHeight = UITableViewAutomaticDimension
+        self.tableView.estimatedRowHeight = 160
+        self.tableView.separatorInset = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0)
+        self.tableView.layoutMargins = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0)
         
-        let tblView = UIView(frame: CGRectZero)
-        tableView.tableFooterView = tblView
-        tableView.tableFooterView?.hidden = true
-        tableView.backgroundColor = UIColor.digipostAccountViewBackground()
+        let tableFooterView = UIView(frame: CGRectZero)
+        self.tableView.tableFooterView = tableFooterView
+        self.tableView.tableFooterView?.hidden = true
+        self.tableView.backgroundColor = UIColor.digipostAccountViewBackground()
         
         self.receiptsTableViewDataSource = UncategorisedReceiptsTableViewDataSource.init(asDataSourceForTableView: self.tableView)
         self.tableView.delegate = self;
-        
-        self.refreshControl = UIRefreshControl.init()
-        self.refreshControl!.initializeRefreshControlText()
-        self.refreshControl!.updateRefreshControlTextRefreshing(true)
-        self.refreshControl!.tintColor = UIColor.init(white: 0.4, alpha: 1.0)
+        self.tableView.addSubview(self.refreshControl)
     }
     
     override func viewWillAppear(animated: Bool) {


import UIKit

class UncategorisedReceiptsViewController: UIViewController, UITableViewDelegate, UIGestureRecognizerDelegate {
    
    @IBOutlet weak var tableView: UITableView!
    

    }
    
    func scrollViewDidScroll(scrollView: UIScrollView) {
        let scrollViewHeight = scrollView.frame.size.height;
        let scrollViewContentSizeHeight = scrollView.contentSize.height;
        let scrollOffset = scrollView.contentOffset.y;
        
        if(self.numberOfReceiptsChangedUponLastUpdate &&
                !self.refreshControl.refreshing &&
                scrollOffset + scrollViewHeight >= 0.8 * scrollViewContentSizeHeight) {
            loadAdditionalReceipts()
        }
    }
    
    func loadAdditionalReceipts() {
        let previousNumberOfReceipts = self.receiptsTableViewDataSource.receipts.count
        self.fetchReceiptsFromAPI()  // this needs to be refactored to get(skip: receipts.count, take: default)
        let updatedNumberOfReceipts = self.receiptsTableViewDataSource.receipts.count
        
        self.numberOfReceiptsChangedUponLastUpdate = (previousNumberOfReceipts == updatedNumberOfReceipts) ? false : true;
    }
