我有这个pickerData:
var pickerData: (id: String, value: [String: String])?
当我点击UITextField时,我会做下一个:
@IBAction func whoCanSee(_ sender: UITextField) {
pickerData = (id: "viewOption", value: ["F": "Me and my friends", "M": "Only certain users", "E": "Every user"])
sender.inputView = self.pickerView
}
以及后来的
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int)
我正在尝试从我的元组中的value
获取值:
self.pickerData!.value.values[row]
但是它返回了我的错误:
Cannot subscript a value of type 'LazyMapCollection<Dictionary<String, String>, String>' with an index of type 'Int'
我也试过了for...in
,但是在这个键中,我总是得到第一个元素,因为每次这个块一次又一次地调用。
如何解决我的问题?
答案 0 :(得分:1)
您正在使用字典,因此您不能只为其提供索引。冷杉
sudo apt install libpq-dev python-dev