-
-
Save laevandus/290342647d911d9900d1d5e6eecb8090 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func numberOfComponents(in pickerView: UIPickerView) -> Int { | |
return 2 | |
} | |
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { | |
return component == 0 ? values.count : units.count | |
} | |
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { | |
if component == 0 { | |
return "\(values[row])" | |
} | |
else { | |
return units[row].rawValue | |
} | |
} | |
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { | |
let valueIndex = pickerView.selectedRow(inComponent: 0) | |
let unitIndex = pickerView.selectedRow(inComponent: 1) | |
selection.wrappedValue = DateDuration(value: values[valueIndex], unit: units[unitIndex]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment