diff --git a/Source/IGListKit/IGListCollectionContext.h b/Source/IGListKit/IGListCollectionContext.h index dcbc2663..9c64e78d 100644 --- a/Source/IGListKit/IGListCollectionContext.h +++ b/Source/IGListKit/IGListCollectionContext.h @@ -208,7 +208,7 @@ NS_SWIFT_NAME(ListCollectionContext) @return A supplementary view dequeued from the reuse pool or a newly created one. - @note This method uses a string representation of the view class as the identifier. + @note This method uses a string representation of the view class and the kind as the identifier. */ - (__kindof UICollectionReusableView *)dequeueReusableSupplementaryViewOfKind:(NSString *)elementKind forSectionController:(IGListSectionController *)sectionController diff --git a/Source/IGListSwiftKit/IGListCollectionContext+Refinements.swift b/Source/IGListSwiftKit/IGListCollectionContext+Refinements.swift index 3da2a52d..54ed020a 100644 --- a/Source/IGListSwiftKit/IGListCollectionContext+Refinements.swift +++ b/Source/IGListSwiftKit/IGListCollectionContext+Refinements.swift @@ -118,4 +118,33 @@ extension ListCollectionContext { return cell } + + /** + Dequeues a supplementary view from the collection view reuse pool. + + - Parameters: + - elementKind: The kind of supplementary view. + - sectionController: The section controller requesting this information. + - index: The index of the supplementary view. + + - Returns: A supplementary view dequeued from the reuse pool or a newly created one. + + - Note: This method uses a string representation of the view class and the kind as the identifier. + */ + public func dequeueReusableSupplementaryView( + ofKind elementKind: String, + forSectionController sectionController: ListSectionController, + atIndex index: NSInteger + ) -> T { + guard let supplementaryView = self.dequeueReusableSupplementaryView( + ofKind: elementKind, + for: sectionController, + class: T.self, + at: index + ) as? T else { + fatalError() + } + + return supplementaryView + } }