CKCollectionViewDataSource Class Reference
| Inherits from | NSObject |
|---|---|
| Declared in | CKCollectionViewDataSource.h |
Overview
This class is an implementation of a UICollectionViewDataSource that can be used along with components. For each set of changes (i.e insertion/deletion/update
of items and/or insertion/deletion of sections) the datasource will compute asynchronously on a background thread the corresponding component trees and then
apply the corresponding UI changes to the collection view leveraging automatic view reuse.
Doing so this reverses the traditional approach for a UICollectionViewDataSource. Usually the controller layer will tell the UICollectionView to update and
then the UICollectionView ask the datasource for the data. Here the model is more Reactive, from an external prospective, the datasource is told what
changes to apply and then tell the collection view to apply the corresponding changes.
– initWithCollectionView:supplementaryViewDataSource:configuration:
The collectionView is held strongly and its datasource property will be set to the receiver.
- (instancetype)initWithCollectionView:(UICollectionView *)collectionView supplementaryViewDataSource:(id<CKSupplementaryViewDataSource>)supplementaryViewDataSource configuration:(CKDataSourceConfiguration *)configurationParameters
collectionView |
The collectionView is held strongly and its datasource property will be set to the receiver. |
|---|---|
supplementaryViewDataSource |
Will be held weakly, pass nil if you don’t need supplementary views. @see the |
Declared In
CKCollectionViewDataSource.h
– applyChangeset:mode:userInfo:
Applies a changeset either synchronously or asynchronously to the collection view. If a synchronous changeset is applied while asynchronous changesets are still pending, then the pending changesets will be applied synchronously before the new changeset is applied.
- (void)applyChangeset:(CKDataSourceChangeset *)changeset mode:(CKUpdateMode)mode userInfo:(NSDictionary *)userInfoDeclared In
CKCollectionViewDataSource.h
– modelForItemAtIndexPath:
The model associated with a certain index path in the collectionView.
- (id<NSObject>)modelForItemAtIndexPath:(NSIndexPath *)indexPathReturn Value
The model associated with a certain index path in the collectionView.
As stated above components are generated asynchronously and on a backgorund thread. This means that a changeset is enqueued and applied asynchronously when the corresponding component tree is generated. For this reason always use this method when you want to retrieve the model associated to a certain index path in the table view (e.g in didSelectRowAtIndexPath: )
Declared In
CKCollectionViewDataSource.h
– sizeForItemAtIndexPath:
The layout size of the component tree at a certain indexPath. Use this to access the component sizes for instance in a
UICollectionViewLayout(s) or in a UICollectionViewDelegateFlowLayout.
- (CGSize)sizeForItemAtIndexPath:(NSIndexPath *)indexPathReturn Value
The layout size of the component tree at a certain indexPath. Use this to access the component sizes for instance in a
UICollectionViewLayout(s) or in a UICollectionViewDelegateFlowLayout.
Declared In
CKCollectionViewDataSource.h
– reloadWithMode:userInfo:
CKDataSource
- (void)reloadWithMode:(CKUpdateMode)mode userInfo:(NSDictionary *)userInfoDeclared In
CKCollectionViewDataSource.h
– updateConfiguration:mode:userInfo:
CKDataSource
- (void)updateConfiguration:(CKDataSourceConfiguration *)configuration mode:(CKUpdateMode)mode userInfo:(NSDictionary *)userInfoDeclared In
CKCollectionViewDataSource.h
– announceWillDisplayCell:
Sends -componentTreeWillAppear to all CKComponentControllers for the given cell. If needed, call this from -collectionView:willDisplayCell:forItemAtIndexPath:
- (void)announceWillDisplayCell:(UICollectionViewCell *)cellDeclared In
CKCollectionViewDataSource.h
– announceDidEndDisplayingCell:
Sends -componentTreeDidDisappear to all CKComponentControllers for the given cell. If needed, call this from -collectionView:didEndDisplayingCell:forItemAtIndexPath:
- (void)announceDidEndDisplayingCell:(UICollectionViewCell *)cellDeclared In
CKCollectionViewDataSource.h
supplementaryViewDataSource
Supplementary views are not handled with components; the datasource will forward any call to
collectionView:viewForSupplementaryElementOfKind:atIndexPath to this object.
@property (readonly, nonatomic, weak) id<CKSupplementaryViewDataSource> supplementaryViewDataSourceDeclared In
CKCollectionViewDataSource.h