Skip to content

Instantly share code, notes, and snippets.

@agrawalsuneet
Last active March 9, 2022 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agrawalsuneet/e36e8998a0e4e313953e8cb0f4e1fb77 to your computer and use it in GitHub Desktop.
Save agrawalsuneet/e36e8998a0e4e313953e8cb0f4e1fb77 to your computer and use it in GitHub Desktop.
Extension to UITextField to add editing event in a clean way
//MARK: - UITextField Extension
@available(iOS 14.0, *)
extension UITextField {
func setOnTextChangeListener(onTextChanged :@escaping () -> Void){
self.addAction(UIAction(){ action in
onTextChanged()
}, for: .editingChanged)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment