IGListCollectionContext typesafe method for dequeueReusableSupplementaryView(ofKind: ... nibName:

Summary: add typesafe method for dequeueReusableSupplementaryView(ofKind: ... nibName:

Reviewed By: natestedman

Differential Revision: D26238618

fbshipit-source-id: 50b99311594fa0987752980025a927da1513b55d
This commit is contained in:
Vivian Phung 2021-02-05 09:34:26 -08:00 committed by Facebook GitHub Bot
parent 6224a6536c
commit 6d6cbe1a2f
2 changed files with 37 additions and 3 deletions

View file

@ -240,7 +240,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 the nib name as the reuse identifier.
*/
- (__kindof UICollectionReusableView *)dequeueReusableSupplementaryViewOfKind:(NSString *)elementKind
forSectionController:(IGListSectionController *)sectionController

View file

@ -147,7 +147,7 @@ extension ListCollectionContext {
return supplementaryView
}
/**
Dequeues a supplementary view from the collection view reuse pool.
@ -173,7 +173,41 @@ extension ListCollectionContext {
) as? T else {
fatalError()
}
return supplementaryView
}
/**
Dequeues a supplementary view from the collection view reuse pool.
- Parameters:
- elementKind: The kind of supplementary view.
- sectionController: The section controller requesting this information.
- 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.
- 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 the nib name as the reuse identifier.
*/
public func dequeueReusableSupplementaryView<T: UICollectionReusableView>(
ofKind elementKind: String,
forSectionController sectionController: ListSectionController,
nibName: String,
bundle: Bundle?,
atIndex index: Int
) -> T {
guard let supplementaryView = self.dequeueReusableSupplementaryView(
ofKind: elementKind,
for: sectionController,
nibName: nibName,
bundle: bundle,
at: index
) as? T else {
fatalError()
}
return supplementaryView
}
}