ASCollectionDataSource Protocol Reference

Conforms to ASCommonCollectionDataSource
Declared in ASCollectionNode.h

Overview

This is a node-based UICollectionViewDataSource.

– collectionNode:numberOfItemsInSection:

Asks the data source for the number of items in the given section of the collection node.

- (NSInteger)collectionNode:(ASCollectionNode *)collectionNode numberOfItemsInSection:(NSInteger)section

Declared In

ASCollectionNode.h

– numberOfSectionsInCollectionNode:

Asks the data source for the number of sections in the collection node.

- (NSInteger)numberOfSectionsInCollectionNode:(ASCollectionNode *)collectionNode

Declared In

ASCollectionNode.h

– collectionNode:nodeBlockForItemAtIndexPath:

Similar to -collectionNode:nodeForItemAtIndexPath: This method takes precedence over collectionNode:nodeForItemAtIndexPath: if implemented.

- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath

Parameters

collectionNode

The sender.

indexPath

The index path of the item.

Return Value

a block that creates the node for display for this item. Must be thread-safe (can be called on the main thread or a background queue) and should not implement reuse (it will be called once per row).

Declared In

ASCollectionNode.h

– collectionNode:nodeForItemAtIndexPath:

Similar to -collectionView:cellForItemAtIndexPath:.

- (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForItemAtIndexPath:(NSIndexPath *)indexPath

Parameters

indexPath

The index path of the item.

collectionView

The sender.

Return Value

A node to display for the given item. This will be called on the main thread and should not implement reuse (it will be called once per item). Unlike UICollectionView’s version, this method is not called when the item is about to display.

Declared In

ASCollectionNode.h

– collectionNode:nodeForSupplementaryElementOfKind:atIndexPath:

Asks the data source to provide a node to display for the given supplementary element in the collection view.

- (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath

Parameters

collectionNode

The sender.

kind

The kind of supplementary element.

indexPath

The index path of the supplementary element.

Declared In

ASCollectionNode.h

– collectionNode:contextForSection:

Asks the data source to provide a context object for the given section. This object can later be retrieved by calling @c contextForSection: and is useful when implementing custom @c UICollectionViewLayout subclasses. The context object is ret

- (nullable id<ASSectionContext>)collectionNode:(ASCollectionNode *)collectionNode contextForSection:(NSInteger)section

Parameters

collectionNode

The sender.

section

The index of the section to provide context for.

Return Value

A context object to assign to the given section, or @c nil.

Declared In

ASCollectionNode.h

– collectionView:nodeForItemAtIndexPath:

Similar to -collectionView:cellForItemAtIndexPath:.

- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForItemAtIndexPath:(NSIndexPath *)indexPath

Parameters

collectionView

The sender.

indexPath

The index path of the requested node.

Return Value

a node for display at this indexpath. This will be called on the main thread and should not implement reuse (it will be called once per row). Unlike UICollectionView’s version, this method is not called when the row is about to display.

Declared In

ASCollectionNode.h

– collectionView:nodeBlockForItemAtIndexPath:

Similar to -collectionView:nodeForItemAtIndexPath: This method takes precedence over collectionView:nodeForItemAtIndexPath: if implemented.

- (ASCellNodeBlock)collectionView:(ASCollectionView *)collectionView nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath

Parameters

collectionView

The sender.

indexPath

The index path of the requested node.

Return Value

a block that creates the node for display at this indexpath. Must be thread-safe (can be called on the main thread or a background queue) and should not implement reuse (it will be called once per row).

Declared In

ASCollectionNode.h

– collectionView:nodeForSupplementaryElementOfKind:atIndexPath:

Asks the collection view to provide a supplementary node to display in the collection view.

- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath

Parameters

collectionView

An object representing the collection view requesting this information.

kind

The kind of supplementary node to provide.

indexPath

The index path that specifies the location of the new supplementary node.

Declared In

ASCollectionNode.h

– collectionViewLockDataSource:

Indicator to lock the data source for data fetching in async mode. We should not update the data source until the data source has been unlocked. Otherwise, it will incur data inconsistency or exception due to the data access in async mode. (Deprecated: The data source is always accessed on the main thread, and this method will not be called.)

- (void)collectionViewLockDataSource:(ASCollectionView *)collectionView

Parameters

collectionView

The sender.

Declared In

ASCollectionNode.h

– collectionViewUnlockDataSource:

Indicator to unlock the data source for data fetching in async mode. We should not update the data source until the data source has been unlocked. Otherwise, it will incur data inconsistency or exception due to the data access in async mode. (Deprecated: The data source is always accessed on the main thread, and this method will not be called.)

- (void)collectionViewUnlockDataSource:(ASCollectionView *)collectionView

Parameters

collectionView

The sender.

Declared In

ASCollectionNode.h