From c7d7b0c91ef0ad7e413022edfcf5d6f75561e2d5 Mon Sep 17 00:00:00 2001 From: Roy Marmelstein Date: Fri, 25 Sep 2020 10:28:18 +0200 Subject: [PATCH] PhoneNumberTextField: mimic UITextFieldDelegate behaviour --- PhoneNumberKit/UI/PhoneNumberTextField.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PhoneNumberKit/UI/PhoneNumberTextField.swift b/PhoneNumberKit/UI/PhoneNumberTextField.swift index fb9053dd7..169b88d70 100644 --- a/PhoneNumberKit/UI/PhoneNumberTextField.swift +++ b/PhoneNumberKit/UI/PhoneNumberTextField.swift @@ -471,7 +471,13 @@ open class PhoneNumberTextField: UITextField, UITextFieldDelegate { @available (iOS 10.0, tvOS 10.0, *) open func textFieldDidEndEditing(_ textField: UITextField, reason: UITextField.DidEndEditingReason) { updateTextFieldDidEndEditing(textField) - self._delegate?.textFieldDidEndEditing?(textField, reason: reason) + if let _delegate = _delegate { + if (_delegate.responds(to: #selector(textFieldDidEndEditing(_:reason:)))) { + _delegate.textFieldDidEndEditing?(textField, reason: reason) + } else { + _delegate.textFieldDidEndEditing?(textField) + } + } } open func textFieldShouldClear(_ textField: UITextField) -> Bool {