title: Swift inserting a cell in uicollectionview gives me an error
body: <p>I have got this code</p>
  
  <pre><code>func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int
  {
      return comments.count
  }
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
          let cell = commentSection.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) as! CommentCell
          return cell
  }
  </code></pre>
  
  <p>And i have functions below this which inserts cells</p>
  
  <pre><code> DispatchQueue.main.async{
                      let indexPath = IndexPath(row: self.comments.count, section: 0)
                      self.commentSection.insertItems(at: [indexPath])
                      self.commentSection.reloadData()
   }
  </code></pre>
  
  <p>But whenever i run this code it prints this error</p>
  
  <pre><code>libc++abi.dylib: terminating with uncaught exception of type NSException
  </code></pre>
  
  <p>And redirects me to AppDelegate file.Even though the error is very clearly written i can't understand the problem</p>