I have an array:
I want to make a picker view with only the names from the array showing. I have previously used button.tag in another VC to find the horseIndex. Is there a way to list only the names in the picker view?
Thanks in advance!
Code Block var myHorses = [ Horse(name: "Donnerhall", idNumber: 1, gender: "Stallion"), Horse(name: "Mischa", idNumber: 2, gender: "Mare")]
I want to make a picker view with only the names from the array showing. I have previously used button.tag in another VC to find the horseIndex. Is there a way to list only the names in the picker view?
Code Block func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { return myHorses[row] //pasted from another VC, maybe something like this can work here var horseName = for horseIndex in myHorses.indices { let horse = myHorses[horseIndex] button.tag = horseIndex }
Thanks in advance!