| ... | @@ -63,9 +63,10 @@ extension Prototype { | ... | @@ -63,9 +63,10 @@ extension Prototype { |
| 63 | field.placeholder = "Name" | 63 | field.placeholder = "Name" |
| 64 | field.textContentType = .name | 64 | field.textContentType = .name |
| 65 | field.autocapitalizationType = .words | 65 | field.autocapitalizationType = .words |
| 66 | NotificationCenter.default.addObserver( | 66 | field.addAction( |
| 67 | forName: UITextField.textDidChangeNotification, object: field, queue: .main | 67 | UIAction { [weak field, weak save] _ in |
| 68 | ) { _ in save.isEnabled = !(field.text ?? "").trimmingCharacters(in: .whitespaces).isEmpty } | 68 | save?.isEnabled = !(field?.text ?? "").trimmingCharacters(in: .whitespaces).isEmpty |
| | 69 | }, for: .editingChanged) |
| 69 | } | 70 | } |
| 70 | alert.addAction(UIAlertAction(title: "Not Now", style: .cancel)) | 71 | alert.addAction(UIAlertAction(title: "Not Now", style: .cancel)) |
| 71 | alert.addAction(save) | 72 | alert.addAction(save) |