From dd7528dfe4d191fb1a8cd90ceae6256f74e37c22 Mon Sep 17 00:00:00 2001 From: Vegard Bieker Matthey Date: Sun, 12 Jul 2026 03:26:08 +0200 Subject: [PATCH] fix: handle collectionView() when metadata == nil --- ImageViewer/ViewController.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ImageViewer/ViewController.swift b/ImageViewer/ViewController.swift index 2bb2d64..41f5322 100644 --- a/ImageViewer/ViewController.swift +++ b/ImageViewer/ViewController.swift @@ -1381,7 +1381,10 @@ extension ViewController: UICollectionViewDataSource, UICollectionViewDelegateFl { if collectionView == comicCollectionView { return comics.count - } else { + } else if collectionView == scrollingCollectionView { + if metadata == nil { + return 0 + } var sum = 0 for volume in metadata.volumes { for chapter in volume.chapters { @@ -1390,6 +1393,7 @@ extension ViewController: UICollectionViewDataSource, UICollectionViewDelegateFl } return sum } + return 0 } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath)