title: Scroll to bottom as new content comes in
body: <p>So I have a <code>UICollectionView</code> that sort of houses a chat function in my app. As users send new messages they are brought in to the app via an observer pattern. However when new content comes in. It ends up below the <code>keyboard</code> and never adjust itself up. When I toggle the <code>keyboard</code> I have a function like this which seems to accomplish this goal. However, when I try similar code in my <code>completion handler</code> it fails and gives me this message.</p>
  
  <blockquote>
    <p>'NSInvalidArgumentException', reason: 'attempt to scroll to invalid index path:  {length = 2, path = 0 - 9}'
    *** First throw call stack:</p>
  </blockquote>
  
  <pre><code>fileprivate func tryObserveComments(){
      print(eventKey)
      commentHandle = ChatService.observeMessages(forChatKey: eventKey) { (ref, newComments) in
          self.commentRer = ref
          self.comments.append(newComments!)
          self.adapter.performUpdates(animated: true)
          let item = self.collectionView.numberOfItems(inSection: self.collectionView.numberOfSections - 1) - 1
          let insertionIndexPath = IndexPath(item: item, section: self.collectionView.numberOfSections - 1)
          self.collectionView.scrollToItem(at: insertionIndexPath, at: UICollectionViewScrollPosition.top, animated: true)
      }
  }
  </code></pre>
  
  <p>Also for some reason in the strange instance that it does work. Some of the <code>keyboard</code> is partially covering the cell</p>