StatesCollectionController
open class StatesCollectionController : CountriesCollectionController
A subclass of CollectionController
that shows a list of states for selection in a CollectionViewController
.
This CollectionController
subclass displays a list of states based from the value of the country code property. The states are retrieved from the user defaults using the defaultsKey
static property value.
The list of countries with states retrieved from the user defaults is encoded with the following JSON format:
{
"name": "<country_name>",
"code": "<country_code>",
"states": [
{
"label": "<state_label_or_name>",
"code": "<state_code>"
}
]
}
The country object contains a name
with a string value of the name of the country, a code
with a string value of the country code and an array of state objects.
The state object contains a label
with a string value of the name/label of the state, and a code
with a string value of the state code.
The default cell used is a StateCollectionViewCell
.
Its nameLabel
is used to display the state name/label.
If the state name/label is empty, the code is displayed instead.
The states displayed are sorted alphabetically by the state’s name/label. If the state’s name/label is empty, the state’s code is used instead for sorting.
Note
Due to what maybe seems to be a bug with the Swift, methods not initially in the superclass and implemented in the subclass may not be executed. To get around this, the method needs to have an@objc
attribue.
-
The country code of the country the states are located.
Declaration
Swift
open var countryCode: String
-
A convenience initializer to pass in the country code and optionally along with the collection view to associated with.
Declaration
Swift
public convenience init(countryCode: String, collectionView: UICollectionView? = nil)
-
Declaration
Swift
override open func registerComponents()
-
Undocumented
Declaration
Swift
override open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
-
Undocumented
Declaration
Swift
override open func loadContent()