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
section
The section and its rows to be stored.
-
Inits with given elements.
Declaration
Swift
public convenience init(sections: [[ElementType]])
Parameters
section
The sections and its rows to be stored.
-
Inits with given elements and its section titles.
Declaration
Swift
public init(sections: [[ElementType]], titles: [String]?)
Parameters
section
The sections and its rows to be stored.
titles
The titles for the given sections. If defined, must have the same length as sections.
-
Returns the element of given
ElementType
at givenindexPath
, if exists.Declaration
Swift
public subscript(indexPath: IndexPath) -> ElementType? { get }
Parameters
indexPath
IndexPath to get object. If the given
indexPath.section
is greater than the amount of stored sections, or if the givenindexPath.row
is 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
element
Object to search.
Return Value
IndexPath.
-
Returns the numbers of stored sections.
Declaration
Swift
public func numberOfSections() -> Int
Return 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) -> Int
Parameters
section
The 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
section
Desired section.
Return Value
String?