Добрый день, есть функция , которая отправляет запрос в добавление друзья. В функции есть UIAlertController с текстовыми полем. Проблема состоит в том , что текст не отправляется . Прошу помощи в решении проблемы. Спасибо
@IBAction func btnInviteFriends(_ sender: Any) {
let alert = UIAlertController(title: "Send request",
message: "to invite to friends",
preferredStyle: .alert)
let submitAction = UIAlertAction(title: "OK", style: .default, handler: { (action) -> Void in
let textField = alert.textFields![0]
// Get 1st TextField's text
RequestClient()
.setURL(self.api.friendsRequest)
.addParam("id", value: self.userId)
.addParam("message", value: self.message)
.setMethod(.post)
.request(completionHandler: { json in
print(json)
})
})
let cancel = UIAlertAction(title: "Cancel", style: .destructive, handler: { (action) -> Void in })
alert.addTextField { (textField: UITextField) in
textField.keyboardAppearance = .dark
textField.keyboardType = .default
textField.autocorrectionType = .default
textField.placeholder = "Your message"
textField.clearButtonMode = .whileEditing
}
alert.addAction(submitAction)
alert.addAction(cancel)
present(alert, animated: true, completion: nil)
}