Ver Fonte

use best practise for dequeueReusableCell() calls

B. Petersen há 2 anos atrás
pai
commit
53b87c1a0f
1 ficheiros alterados com 1 adições e 5 exclusões
  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