Created
October 23, 2017 04:59
-
-
Save azamsharp/5b999b676d12fa785e176df6c137fcb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment