CollectionDataProvider
open class CollectionDataProvider<ItemType>
Class representing Data to be used in a collection view.
This class manages a two dimensional array of an associated item type. The first dimension of the array serves as an indicator of the section while the second dimension are the items in the section.
-
A two dimensional array of the generic item type.
Declaration
Swift
open var items: [[ItemType]] -
The index path of the last item. This value is nil if
itemsis empty.Declaration
Swift
open var lastIndexPath: IndexPath? { get } -
Returns a newly initialized collection data provider with the specified two dimensional array of an item type.
Declaration
Swift
public convenience init(items: [[ItemType]])Parameters
itemsA two dimensional array of an item type.
Return Value
The initialized collection data provider.
-
Returns a newly initialized collection data provided with the specified array of an item type. The given array will be put into another array to be identified as a two dimensional array.
Declaration
Swift
public convenience init(sectionItems: [ItemType])Parameters
itemsAn array of an item type.
Return Value
The initialized collection data provider.
-
Returns the number of sections contained in the items array.
Declaration
Swift
open func numberOfSections() -> IntReturn Value
An
Intvalue representing the number of sections. -
Returns the number of items for the specified section contained in the items array.
Declaration
Swift
open func numberOfItems(in section: Int) -> IntParameters
sectionThe section to get the number of items.
Return Value
An
Intvalue representing the number of items in the specified section. If section is out of bounds, this returns zero. -
Returns the item for the specified index path contained in the items array.
Declaration
Swift
open func item(at indexPath: IndexPath) -> ItemType?Parameters
indexPathThe
IndexPathof the item.Return Value
An optional value with the generic item type. The optional value is nil if the index path is out of bounds
-
Returns items for the specified section contained in the items array.
Declaration
Swift
open func items(atSection section: Int) -> [ItemType]Parameters
sectionThe section of the items.
Return Value
An array of the generic item type. The array will be empty if the section is out of bounds.
-
Adds an item to the items array. The added item will be appended in the last section.
Declaration
Swift
@discardableResult open func add(_ item: ItemType) -> IndexPathParameters
itemAn object of the generic item type.
Return Value
The
IndexPathof the added item. -
Adds items to the items array. The added items will be appended in the last section.
Declaration
Swift
@discardableResult open func add(_ items: [ItemType]) -> [IndexPath]Parameters
itemsAn array of the generic item type.
Return Value
An array of
IndexPaths of the added items. -
Updates an item in the items array.
If index path is out of bounds, this does nothing.
Declaration
Swift
open func updateItem(at indexPath: IndexPath, value: ItemType)Parameters
indexPathThe
IndexPathof the item to update.valueThe updated object of the generic item type.
-
Removes an item in the items array.
If index path is out of bounds, this does nothing.
Declaration
Swift
open func remove(at indexPath: IndexPath)Parameters
indexPathThe
IndexPathof the item to remove. -
Removes all items in the items array.
Declaration
Swift
open func removeAllItems()
View on GitHub
CollectionDataProvider Class Reference