FUIListPickerDataSource
@objc
public protocol FUIListPickerDataSource
An object that adopts the FUIListPickerDataSource protocol is responsible for
providing the data and views required to display the list of options
available in FUIListPickerFormCell or FUIListPickerTableViewController.
The data source could be sectioned by implementing the following function:
func numberOfSections(in listPicker: FUIListPicker) -> Int
Important
Only data source using unique identifier could be sectioned. That is, the propertyisDataSourceRequiringUniqueIdentifiers of the FUIListPicker is true.
Implementation Note:
The list picker will not show any item if any of the required functions is not implemented.
The following optional functions are required to be implemented for data source not using unique identifier:
func numberOfRows(in listPickerTableView: UITableView) -> Int
func listPickerTableView(_ tableView: UITableView, cellForRowAt index: Int, isFiltered: Bool) -> UITableViewCell
The following optional functions are required to be implemented for data source using unique identifier but not sectioned:
func numberOfRows(in listPickerTableView: UITableView) -> Int
func listPickerTableView(_ tableView: UITableView, cellForRowAt index: Int, isFiltered: Bool) -> UITableViewCell
func listPickerTableView(_ tableView: UITableView, cellForItemWithUniqueIdentifier uniqueIdentifier: String) -> UITableViewCell
func listPickerTableView(_ tableView: UITableView, uniqueIdentifierForItemAt index: Int) -> String
func listPickerTableView(_ tableView: UITableView, indexForUniqueIdentifier uniqueIdentifier: String) -> Int
The following optional functions are required to be implemented for data source using unique identifier and sectioned:
func numberOfSections(in listPicker: FUIListPicker) -> Int
func listPickerTableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
func listPickerTableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath, isFiltered: Bool) -> UITableViewCell
func listPickerTableView(_ tableView: UITableView, uniqueIdentifierForItemAtIndexPath indexPath: IndexPath) -> String
func listPickerTableView(_ tableView: UITableView, cellForItemWithUniqueIdentifier uniqueIdentifier: String) -> UITableViewCell
func listPickerTableView(_ tableView: UITableView, indexPathForUniqueIdentifier uniqueIdentifier: String) -> IndexPath?
-
Gets the number of rows to be displayed.
Important
This function is required if the data source is not sectioned.Declaration
Swift
@objc optional func numberOfRows(in listPickerTableView: UITableView) -> IntParameters
listPickerTableViewThe
UITableViewfor the list to be displaye.Return Value
If a search is in effect, returns the number of rows in filtered data. Otherwise, returns the number of rows in the original options.
-
This function should return a
UITableViewCellat the index position. If isFiltered is true, the index is to the filtered list. If isFiltered is false, the index is to the unfiltered list.Important
This function is required if the data source is not sectioned.Declaration
Swift
@objc optional func listPickerTableView(_ tableView: UITableView, cellForRowAt index: Int, isFiltered: Bool) -> UITableViewCellParameters
tableViewThe
UITableViewfor the cell to be displayed.indexThe index to the array of the items for the cell to be displayed.
isFilteredIndicates if the index is to the filtered array or not.
Return Value
The
UITableViewCellto be displayed. -
This function should return a
UITableViewCellfor the specified Unique Identifier. This is typically used for displaying the selected list in the table view.Important
This function is required if the propertyisDataSourceRequiringUniqueIdentifiersof theFUIListPickeris true.Declaration
Swift
@objc optional func listPickerTableView(_ tableView: UITableView, cellForItemWithUniqueIdentifier uniqueIdentifier: String) -> UITableViewCellParameters
tableViewThe
UITableViewfor the cell to be displayed.uniqueIdentifierThe Unique Identifier for the item in the list.
-
Obtain the Unique Identifier at the current index, whether the list is filtered or not.
Important
This function is required if the propertyisDataSourceRequiringUniqueIdentifiersof theFUIListPickeris true, but is not a “sectioned” data source.Declaration
Swift
@objc optional func listPickerTableView(_ tableView: UITableView, uniqueIdentifierForItemAt index: Int) -> StringParameters
tableViewThe
UITableViewfor the list picker.indexThe index to the current array of items, whether it is filtered or not.
Return Value
The Unique Identifier for the item at the index location.
-
Obtain the index to the current list, whether the list is filtered or not.
Important
This function is required if the propertyisDataSourceRequiringUniqueIdentifiersof theFUIListPickeris true, but is not a “sectioned” data source.Declaration
Swift
@objc optional func listPickerTableView(_ tableView: UITableView, indexForUniqueIdentifier uniqueIdentifier: String) -> IntParameters
tableViewThe
UITableViewfor the list picker.uniqueIdentifierThe Unique Identifier for the item in the list.
Return Value
The index to the current list for the unique identifier. Or, -1 if the unique identifier is not in the current list.
-
Asks the data source for the number of sections in the data source.
Important
This function is ignored if the propertyisDataSourceRequiringUniqueIdentifiersof theFUIListPickeris false. This data source is a “sectioned” data source if this function is implemented and the propertyisDataSourceRequiringUniqueIdentifiersof theFUIListPickeris true. There are other functions required to be implemented in a “sectioned” data source.Declaration
Swift
@objc optional func numberOfSections(in listPicker: FUIListPicker) -> IntParameters
listPickerThe
FUIListPickerfor the data source.Return Value
The number of sections in this data source.
-
Asks the data source for the number of rows in the specified section.
Important
This function is required for a “sectioned” data source.Declaration
Swift
@objc optional func listPickerTableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> IntParameters
tableViewThe
UITableViewfor the list picker.sectionThe specified section.
Return Value
The number of rows in the specified section.
-
Asks the data source for the header title of the specified section.
Important
This function is invoked only if this is a “sectioned” data source. There is no section header title when this function is not implemented.Declaration
Swift
@objc optional func listPickerTableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String?Parameters
tableViewThe
UITableViewfor the list picker.sectionThe specified section.
Return Value
The header title for the specified section.
-
This function should return a
UITableViewCellat theIndexPathposition.If
isFilteredis true, the index is to the filtered list. IfisFilteredis false, the index is to the unfiltered list.Important
This function is required for a “sectioned” data source.Declaration
Swift
@objc optional func listPickerTableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath, isFiltered: Bool) -> UITableViewCellParameters
tableViewThe
UITableViewfor the cell to be displayed.indexPathThe
IndexPathto the array of the items for the cell to be displayed.isFilteredIndicates if the
IndexPathis to the filtered array or not.Return Value
The
UITableViewCellto be displayed. -
Obtain the Unique Identifier at the specified
IndexPath, whether the list is filtered or not.Important
This function is required for a “sectioned” data source.Declaration
Swift
@objc optional func listPickerTableView(_ tableView: UITableView, uniqueIdentifierForItemAtIndexPath indexPath: IndexPath) -> StringParameters
tableViewThe
UITableViewfor the list picker.indexPathThe
IndexPathto the current list of items, whether it is filtered or not.Return Value
The Unique Identifier for the item at the
IndexPathlocation. -
Obtain the
IndexPathto the current list, whether the list is filtered or not.Important
This function is required for a “sectioned” data source.Declaration
Swift
@objc optional func listPickerTableView(_ tableView: UITableView, indexPathForUniqueIdentifier uniqueIdentifier: String) -> IndexPath?Parameters
tableViewThe
UITableViewfor the list picker.uniqueIdentifierThe Unique Identifier for the item in the list.
Return Value
The
IndexPathto the current list for the unique identifier. Or, nil if the unique identifier is not in the current list. -
Obtain the list of all unique identifiers for this “Unique Identifier” type data source.
For “Unique Identifier” type data sources, if this optional function is implemented, and returns a non-nil value, the “Select All” button will be shown. Otherwise, the “Select All” button will not be shown.
This function has no effect on non-“Unique Identifier” type data sources.
Declaration
Swift
@objc optional func allUniqueIdentifiers(in listPicker: FUIListPicker) -> [String]?