IGListCollectionContext typesafe method for dequeueReusableSupplementaryView(:ofKind

Summary: add typesafe method for dequeueReusableSupplementaryView(:ofKind

Reviewed By: natestedman

Differential Revision: D26238603

fbshipit-source-id: 178bee6da1957a132c73610b9db0796323cbff26
This commit is contained in:
Vivian Phung 2021-02-05 09:34:26 -08:00 committed by Facebook GitHub Bot
parent f3abdcac0d
commit dd3726343d
2 changed files with 30 additions and 1 deletions

View file

@ -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

View file

@ -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<T: UICollectionReusableView>(
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
}
}