我想在pickerview行上给出条件,但它只是给我错误。 二进制运算符不能应用于操作数。
let viewList: [String] = ["Fixed", "Recurring"]
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if (viewList[row] == 0) {
}
}
答案 0 :(得分:0)
更新回答
尝试这样做:
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!")
}
}
}
问题来自您的情况,请尝试下面的代码。