I have a picker view. I am able to capture the String
out of the picker view, but really I just want the index
. I thought maybe the selectedRow(InComponent: Int)
would work, but when I try this I get a crash saying
index 2 beyond bounds [0 .. 0]
This is what I am trying
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, InComponent component: Int) {
timeFrame = fixedAmountPickerView.selectedRow(inComponent: row)
}
What can I do to get the Index
as an Int
?
You can get the index in different ways:
didSelectRow
the row
parameter is your selected rowfixedAmountPickerView.selectedRow(inComponent: 0)
if you´re outside the didSelectRow