Przeglądaj źródła

use best practise for dequeueReusableCell() calls

B. Petersen 2 lat temu
rodzic
commit
53b87c1a0f

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

@@ -185,11 +185,7 @@ extension GalleryViewController: UICollectionViewDataSource, UICollectionViewDel
     }
 
     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]
         var item: GalleryItem