IGListCollectionContext typesafe method for dequeueReusableCellFromStoryboard

Summary: add typesafe method for dequeueReusableCellFromStoryboard

Reviewed By: natestedman

Differential Revision: D26238579

fbshipit-source-id: 11e09b4487b2d64b1be53530358922e98b00cd33
This commit is contained in:
Vivian Phung 2021-02-05 09:34:26 -08:00 committed by Facebook GitHub Bot
parent 7b26f4f32e
commit f3abdcac0d

View file

@ -92,4 +92,30 @@ extension ListCollectionContext {
return cell
}
/**
Dequeues a storyboard prototype cell from the collection view reuse pool.
- Parameters:
- identifier: The identifier of the cell prototype in storyboard.
- 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.
*/
public func dequeueReusableCellFromStoryboard<T: UICollectionViewCell>(
withIdentifier reuseIdentifier: String,
for sectionController: ListSectionController,
at index: Int
) -> T {
guard let cell = self.dequeueReusableCellFromStoryboard(
withIdentifier: reuseIdentifier,
for: sectionController,
at: index
) as? T else {
fatalError("A cell with the identifier \"\(reuseIdentifier)\" was not found in the storyboard")
}
return cell
}
}