I am trying to get the value of a tapered row in a UIPickerView but every time I scroll through it, it gives me every value I go through. How can I get the value of when the user taps the row?
I am trying to append the value that the user clicks on to an array called squaresTaken.
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
pickerData.count
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
intToString()
return pickerData[row]
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
squaresTaken.append(Int(pickerData[row])!)
yourSquare.text = pickerData[row]
}