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) -> Int
Parameters
listPickerTableView
The
UITableView
for 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
UITableViewCell
at 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) -> UITableViewCell
Parameters
tableView
The
UITableView
for the cell to be displayed.index
The index to the array of the items for the cell to be displayed.
isFiltered
Indicates if the index is to the filtered array or not.
Return Value
The
UITableViewCell
to be displayed. -
This function should return a
UITableViewCell
for the specified Unique Identifier. This is typically used for displaying the selected list in the table view.Important
This function is required if the propertyisDataSourceRequiringUniqueIdentifiers
of theFUIListPicker
is true.Declaration
Swift
@objc optional func listPickerTableView(_ tableView: UITableView, cellForItemWithUniqueIdentifier uniqueIdentifier: String) -> UITableViewCell
Parameters
tableView
The
UITableView
for the cell to be displayed.uniqueIdentifier
The 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 propertyisDataSourceRequiringUniqueIdentifiers
of theFUIListPicker
is true, but is not a “sectioned” data source.Declaration
Swift
@objc optional func listPickerTableView(_ tableView: UITableView, uniqueIdentifierForItemAt index: Int) -> String
Parameters
tableView
The
UITableView
for the list picker.index
The 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 propertyisDataSourceRequiringUniqueIdentifiers
of theFUIListPicker
is true, but is not a “sectioned” data source.Declaration
Swift
@objc optional func listPickerTableView(_ tableView: UITableView, indexForUniqueIdentifier uniqueIdentifier: String) -> Int
Parameters
tableView
The
UITableView
for the list picker.uniqueIdentifier
The 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 propertyisDataSourceRequiringUniqueIdentifiers
of theFUIListPicker
is false. This data source is a “sectioned” data source if this function is implemented and the propertyisDataSourceRequiringUniqueIdentifiers
of theFUIListPicker
is true. There are other functions required to be implemented in a “sectioned” data source.Declaration
Swift
@objc optional func numberOfSections(in listPicker: FUIListPicker) -> Int
Parameters
listPicker
The
FUIListPicker
for 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) -> Int
Parameters
tableView
The
UITableView
for the list picker.section
The 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
tableView
The
UITableView
for the list picker.section
The specified section.
Return Value
The header title for the specified section.
-
This function should return a
UITableViewCell
at theIndexPath
position.If
isFiltered
is true, the index is to the filtered list. IfisFiltered
is 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) -> UITableViewCell
Parameters
tableView
The
UITableView
for the cell to be displayed.indexPath
The
IndexPath
to the array of the items for the cell to be displayed.isFiltered
Indicates if the
IndexPath
is to the filtered array or not.Return Value
The
UITableViewCell
to 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) -> String
Parameters
tableView
The
UITableView
for the list picker.indexPath
The
IndexPath
to the current list of items, whether it is filtered or not.Return Value
The Unique Identifier for the item at the
IndexPath
location. -
Obtain the
IndexPath
to 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
tableView
The
UITableView
for the list picker.uniqueIdentifier
The Unique Identifier for the item in the list.
Return Value
The
IndexPath
to 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, 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 allUniqueIdentifier(in listPicker: FUIListPicker) -> [String]