Do it like this(for Swift 3):
class MyClass: UIScrollViewDelegate { func scrollViewDidScroll(_ scrollView: UIScrollView) { if (scrollView.contentOffset.y >= (scrollView.contentSize.height - scrollView.frame.size.height)) { //scrolled to top, do smth } }}