Browse Source

use best practise for dequeueReusableCell() calls

B. Petersen 2 years ago
parent
commit
53b87c1a0f
1 changed files with 1 additions and 5 deletions
  1. 1 5
      deltachat-ios/Controller/GalleryViewController.swift

+ 1 - 5
deltachat-ios/Controller/GalleryViewController.swift

@@ -185,11 +185,7 @@ extension GalleryViewController: UICollectionViewDataSource, UICollectionViewDel
     }
     }
 
 
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-        guard let galleryCell = collectionView.dequeueReusableCell(
-                withReuseIdentifier: GalleryCell.reuseIdentifier,
-                for: indexPath) as? GalleryCell else {
-            return UICollectionViewCell()
-        }
+        let galleryCell = collectionView.dequeueReusableCell(withReuseIdentifier: GalleryCell.reuseIdentifier, for: indexPath) as? GalleryCell ?? GalleryCell()
 
 
         let msgId = mediaMessageIds[indexPath.row]
         let msgId = mediaMessageIds[indexPath.row]
         var item: GalleryItem
         var item: GalleryItem