diff --git a/Source/IGListKit/IGListCollectionContext.h b/Source/IGListKit/IGListCollectionContext.h index be16b3ea..dcbc2663 100644 --- a/Source/IGListKit/IGListCollectionContext.h +++ b/Source/IGListKit/IGListCollectionContext.h @@ -178,7 +178,7 @@ NS_SWIFT_NAME(ListCollectionContext) @return A cell dequeued from the reuse pool or a newly created one. - @note This method uses a string representation of the cell class as the identifier. + @note This method uses the nib name as the reuse identifier. */ - (__kindof UICollectionViewCell *)dequeueReusableCellWithNibName:(NSString *)nibName bundle:(nullable NSBundle *)bundle diff --git a/Source/IGListSwiftKit/IGListCollectionContext+Refinements.swift b/Source/IGListSwiftKit/IGListCollectionContext+Refinements.swift index 14212be4..cd4ccaad 100644 --- a/Source/IGListSwiftKit/IGListCollectionContext+Refinements.swift +++ b/Source/IGListSwiftKit/IGListCollectionContext+Refinements.swift @@ -53,11 +53,43 @@ extension ListCollectionContext { ) -> T { guard let cell = self.dequeueReusableCell( of: T.self, - for: sectionController, at: index + for: sectionController, + at: index ) as? T else { fatalError() } return cell } + + /** + Dequeues a cell from the collection view reuse pool. + + - Parameters: + - nibName: The name of the nib file. + - bundle: The bundle in which to search for the nib file. If `nil`, this method searches the main bundle. + - sectionController: The section controller requesting this information. + - index: The index of the cell. + + - Returns: A cell dequeued from the reuse pool or a newly created one. + + - Note: This method uses the nib name as the reuse identifier. + */ + public func dequeueReusableCell( + withNibName nibName: String, + bundle: Bundle?, + for sectionController: ListSectionController, + at index: Int + ) -> T { + guard let cell = self.dequeueReusableCell( + withNibName: nibName, + bundle: bundle, + for: sectionController, + at: index + ) as? T else { + fatalError("A nib named \"\(nibName)\" was not found in \(bundle)") + } + + return cell + } }