title: Indexpath Out of Range in My Array, Fatal Error in videoArray - Swift
body: <p>I'm getting and index path out of range error, but even when I check the code, I clearly having data in my array. Is it possible to safely unwrap it, or maybe somehow get over the error? I'm not sure exactly how.</p>
  <p>I'm sure its an easy solution and I'm probably just overlooking it.</p>
  <p>Error occurring inside of generatecellforthumbnail()</p>
  <pre><code>extension dashboard :UICollectionViewDataSource{
  
  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
     if (collectionView == shopCollectionView){
      return myCategoryArray.count
     }
     
      return videoThumbnailArray.count
  }
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      
      let cell = VideoCollectionView.dequeueReusableCell(withReuseIdentifier: &quot;CollectionCell1&quot;, for: indexPath) as! videoCollectionCell
      
      
          cell.generateCellForThumbnail(model: videoThumbnailArray[indexPath.row])
      
      
      
  
      if (shopCollectionView == collectionView) {
          let cell2 = shopCollectionView.dequeueReusableCell(withReuseIdentifier: &quot;ShopCell1&quot;, for: indexPath) as! ShopCategoryCollectionViewCell
          
          cell2.generateCellforCategory(myCategoryArray[indexPath.row])
          return cell2
      }
      
      return cell
  }
  </code></pre>
  <p>}</p>