IGListBindingSectionControllerDataSource
Objective-C
@protocol IGListBindingSectionControllerDataSource <NSObject>
Swift
protocol ListBindingSectionControllerDataSource : NSObjectProtocol
A protocol that returns data to power cells in an IGListBindingSectionController
.
-
Create an array of view models given a top-level object.
Declaration
Objective-C
- (nonnull NSArray<id<IGListDiffable>> *) sectionController: (nonnull IGListBindingSectionController *)sectionController viewModelsForObject:(nonnull id)object;
Swift
func sectionController(_ sectionController: IGListBindingSectionController, viewModelsFor object: Any) -> [any IGListDiffable]
Parameters
sectionController
The section controller requesting view models.
object
The top-level object that powers the section controller.
Return Value
A new array of view models.
-
Return a dequeued cell for a given view model.
Note
The section controller will call
-bindViewModel:
with the provided view model after the cell is dequeued. You should handle cell configuration using this method. However, you can do additional configuration at this stage as well.Declaration
Objective-C
- (nonnull UICollectionViewCell<IGListBindable> *) sectionController: (nonnull IGListBindingSectionController *)sectionController cellForViewModel:(nonnull id)viewModel atIndex:(NSInteger)index;
Swift
func sectionController(_ sectionController: IGListBindingSectionController, cellForViewModel viewModel: Any, at index: Int) -> any UICollectionViewCell & IGListBindable
Parameters
sectionController
The section controller requesting a cell.
viewModel
The view model for the cell.
index
The index of the view model.
Return Value
A dequeued cell.
-
Return a cell size for a given view model.
Declaration
Objective-C
- (CGSize)sectionController: (nonnull IGListBindingSectionController *)sectionController sizeForViewModel:(nonnull id)viewModel atIndex:(NSInteger)index;
Swift
func sectionController(_ sectionController: IGListBindingSectionController, sizeForViewModel viewModel: Any, at index: Int) -> CGSize
Parameters
sectionController
The section controller requesting a size.
viewModel
The view model for the cell.
index
The index of the view model.
Return Value
A size for the view model.