IGListCollectionContext typesafe method for dequeueReusableSupplementaryView(fromStoryboardOfKind:

Summary: add typesafe method for dequeueReusableSupplementaryView(fromStoryboardOfKind:

Reviewed By: natestedman

Differential Revision: D26238613

fbshipit-source-id: 15d18628fd54e2d7d0ff3cb0b1f88bb473bfbfed
This commit is contained in:
Vivian Phung 2021-02-05 09:34:26 -08:00 committed by Facebook GitHub Bot
parent dd3726343d
commit 6224a6536c

View file

@ -147,4 +147,33 @@ extension ListCollectionContext {
return supplementaryView
}
/**
Dequeues a supplementary view from the collection view reuse pool.
- Parameters:
- elementKind: The kind of supplementary view.
- identifier: The identifier of the supplementary view in storyboard.
- 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.
*/
public func dequeueReusableSupplementaryViewFromStoryboard<T: UICollectionReusableView>(
ofKind elementKind: String,
withIdentifier identifier: String,
forSectionController sectionController: ListSectionController,
atIndex index: Int
) -> T {
guard let supplementaryView = self.dequeueReusableSupplementaryView(
fromStoryboardOfKind: elementKind,
withIdentifier: identifier,
for: sectionController,
at: index
) as? T else {
fatalError()
}
return supplementaryView
}
}