I want to give condition on pickerview row, but it just giving me error. Binary operator cannot be applied to operands.
let viewList: [String] = ["Fixed", "Recurring"]
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if (viewList[row] == 0) {
}
}
Updated answer
Try to do like this:
class MyViewController: UIViewController {
fileprivate let viewList: [String] = ["Fixed", "Recurring"]
}
// MARK: - UIPickerViewDelegate
extension MyViewController: UIPickerViewDelegate {
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
print("Selected value \(viewList[row]) at row \(row)")
if viewList[row] == "Fixed" {
print("Fixed has been selected!")
}
}
}
The problem come from your condition, try the code below.
More information: Apple Documentation - Collection Types