I've seen a lot of answers, but it seems that none of them has worked. I have a programmatically created UIAlertView with two UITextFields. I want to restrict the number of characters :
- 12 characters in first field
- 1 character in second field
First field code:
alertDialog.addTextField { (nameField) in
nameField.placeholder = "Name"
nameField.borderStyle = .roundedRect
nameField.clearButtonMode = .whileEditing
}
And second
alertDialog.addTextField { (keyField) in
keyField.placeholder = "Key"
keyField.borderStyle = .roundedRect
keyField.clearButtonMode = .whileEditing
}
How can I correctly restrict the number (Let's pretend that there will be no paste in these field)