i have created a alert with two textfields and the inputView of the second texfield is a pickerview. I can access the text of the first textfield by alert.textfields?.first?.text. I want to display the picker view items in the second textfield, but i dont know how to access the secondTextfield.text in the picker view function didSelectRow. how can i fix it ?
buttonAnimation(button: addButton)
passwordStringArray.insert("\(passwordLabel.text ?? "")", at: 0)
let alert = UIAlertController(title: "\(passwordLabel.text ?? "")", message: "customize your password", preferredStyle: .alert)
alert.addTextField { (notesTextfield) in
notesTextfield.placeholder = "type in some notes"
notesTextfield.textAlignment = .center
}
alert.addTextField { (categoryTextfield) in
categoryTextfield.placeholder = "choose your password category"
categoryTextfield.textAlignment = .center
categoryTextfield.inputView = self.picker
}
let actionSave = UIAlertAction(title: "save", style: .default) { (cancelButton) in
self.dismiss(animated: true, completion: nil)
self.passwordNotesArray.insert("\(alert.textFields?.first?.text ?? "")", at: 0)
// self.passwordCategory.insert(categorytextfield.text)
self.performSegue(withIdentifier: "segue", sender: self)
}
let actionCancel = UIAlertAction(title: "cancel", style: .default) { (saveButton) in
self.dismiss(animated: true, completion: nil)
}
alert.addAction(actionCancel)
alert.addAction(actionSave)
self.present(alert, animated: true)
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
// how can i access alert.textfield.categorytectfield.text here ?
}