ArrayDataProvider
open class ArrayDataProvider<ElementType> : NSObject, DataProvider where ElementType : Equatable
Matrix-based generic data provider having elements of type ElementType.
Begin matrix-based allows this data provider to work both as single-sectioned (array) and multi-sectiond (matrix) without changes.
Methods that receive a single section as parameter, will handle data as an array (rows only), while methods that receive multiple sections as parameter will handle data as an matrix, begin translatable as sections and rows.
-
Inits with given elements. Data will be handled as a single section array.
Declaration
Swift
public convenience init(section: [ElementType])Parameters
sectionThe section and its rows to be stored.
-
Inits with given elements.
Declaration
Swift
public convenience init(sections: [[ElementType]])Parameters
sectionThe sections and its rows to be stored.
-
Inits with given elements and its section titles.
Declaration
Swift
public init(sections: [[ElementType]], titles: [String]?)Parameters
sectionThe sections and its rows to be stored.
titlesThe titles for the given sections. If defined, must have the same length as sections.
-
Returns the element of given
ElementTypeat givenindexPath, if exists.Declaration
Swift
public subscript(indexPath: IndexPath) -> ElementType? { get }Parameters
indexPathIndexPath to get object. If the given
indexPath.sectionis greater than the amount of stored sections, or if the givenindexPath.rowis greater than the amount of rows for given section, returns nil. -
Returns the IndexPath for the given element, if found.
Declaration
Swift
public func path(for element: ElementType) -> IndexPath?Parameters
elementObject to search.
Return Value
IndexPath.
-
Returns the numbers of stored sections.
Declaration
Swift
public func numberOfSections() -> IntReturn Value
Int.
-
Returns the number of elements in the given section.
Remarks
If given section does not exists, returns 0.
Declaration
Swift
public func numberOfItems(in section: Int) -> IntParameters
sectionThe section to be inquired about how much rows it has.
Return Value
Int.
-
Returns the title for a given section.
Declaration
Swift
public func title(section: Int) -> String?Parameters
sectionDesired section.
Return Value
String?
View on GitHub
ArrayDataProvider Class Reference