Skip to content

Commit c75e00f

Browse files
Use a guard and provide a fatal error with message
1 parent 6dc945b commit c75e00f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/CombineDataSources/CollectionView/CollectionViewItemsController.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ public class CollectionViewItemsController<CollectionType>: NSObject, UICollecti
102102
}
103103

104104
public func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
105-
return configureSupplementaryView!(self, collectionView, kind, indexPath, collection[indexPath.section])
105+
guard let configureSupplementaryView = configureSupplementaryView else {
106+
fatalError("Property `configureSupplementaryView` must not be nil when using supplementary views")
107+
}
108+
return configureSupplementaryView(self, collectionView, kind, indexPath, collection[indexPath.section])
106109
}
107110

108111
// MARK: - Fallback data source object

0 commit comments

Comments
 (0)