Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- import UIKit
- class BindingTextField : UITextField {
- var textChanged :(String) -> () = { _ in }
- func bind(callback :@escaping (String) -> ()) {
- self.textChanged = callback
- self.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
- }
- @objc func textFieldDidChange(_ textField :UITextField) {
- self.textChanged(textField.text!)
- }
- }
Add Comment
Please, Sign In to add comment