title: How to fix collection View refresh error in swift 4
body: <p>I'm getting an error while trying to refresh my collectionView which is strange because it was working perfect last I ran the app. The error is "Thread 1: Fatal error: Index out of range"</p>
  
  <pre><code>func setupRefreshControl() {
  
      let refreshControl = UIRefreshControl()
      refreshControl.addTarget(self, action: #selector(handleRefresh), for: .valueChanged)
      collectionView?.refreshControl = refreshControl
  }
  
  @objc func handleUpdateFeed() {
      handleRefresh()
  }
  
  fileprivate func fetchallPosts() {
      fetchPostUserIds()
      fetchPosts()
  }
  
  @objc func handleRefresh() {
      print("Handling refresh..")
      posts.removeAll()
      fetchPostUserIds()
  }
  </code></pre>