Most of the example I found is in Objective - C
which is very hard for me to understand can someone provide an example regarding this question in Swift
. Here is one solution but it is in Objective C
.
func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
print("after every text gets changed")
timer.invalidate()
timer = NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: #selector(ViewController.output), userInfo: searchText, repeats: false)
}
func output(){
print("hello")
if timer.userInfo != nil {
print(timer.userInfo)
}
timer.invalidate()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With